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.

oracle table

Here is my code:

$user = new User;
$user->username = 'lolol';
$user->name = 'lolol';
$user->email = '[email protected]';
$user->domain = 'lolol';
$user->active_directory = 0;

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.




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.

//other User model methods....
public function setActiveDirectoryAttribute($attrValue){
    $this->attributes['active_directory'] = (string) $attrValue;

People are also looking for solutions to the problem: php - How to map one class variable to two form fields in Symfony


Didn't find the answer?

Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.

Ask a Question

Write quick answer

Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.

Similar questions

Find the answer in similar questions on our website.