php - Laravel 5.2 eloquent save() method store number 0 in Oracle become 4294967296
I'm having a problem when saving data with eloquent save() method.
For example when I insert a number like 0, the number in the table become 4294967296.
Here is my code:
$user = new User;
$user->username = 'lolol';
$user->name = 'lolol';
$user->email = '[email protected]';
$user->domain = 'lolol';
$user->active_directory = 0;
$user->save();
But, there is no problem when I'm using raw query like this:
DB::insert('insert into users (id, username, name, email, active_directory, domain) values (?, ?, ?, ?, ?, ?)', [10,'dayle', 'Dayle', 'dayle', '0', 'esdm']);
it will insert 0 into table.
Is there any way to solve this problem?
Thank you for your help and answer.
Answer
Solution:
There may indeed be a bug here, but considering passing the query a string instead of a integer works, a simple workaround would be to implement a setter mutator inside your User model which casts your active_directory attribute to string before saving it.