C
C
cyrildotcom2016-03-25 09:55:41
Laravel
cyrildotcom, 2016-03-25 09:55:41

How to overload the type of a variable depending on the runtime?

Suppose there is a site on laravel, a production server on ubuntu and a dev server on windows
The problem is that an identical request to the database through eloquent ORM is processed differently on different servers.
For example, App\User::find(1)->where('some_field', 0) on windows is expected, but on linux only if the value of the 'some_field' argument is specified in quotes, i.e. '0'. Same thing with tinker. The some_fields field type in mysql is specified as tinyint.
Is it possible to change the type of a variable depending on which server the script is running on?
For example, $id=0, or $id='0'

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Silm, 2016-03-25
@cyrildotcom

Laravel has an environment setting: https://laravel.com/docs/5.2/configuration#environ...
But why are you fixing the effect instead of the cause?
Get rid of the windows server, at least for those projects that will be in production on Linux. How could there be a problem here?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question