Larvel 4.2 BIT data type

there is a type column in the database table bit(1). but it does not work, as I expected.

problem

$invitee = new Invitee();
$invitee->name = "name1";
$invitee->email = "example@mail.com";
$invitee->isActive = 0;    // "b'0'", '0', false,   are also not working
$invitee->save();

I need to put a zero 0in a column isActive, but its getting a value 1every time I try to add a record with 0.

and I found the question in here. . but the answers do not describe the cause of the problem. glad if someone can explain the problem.

+4
source share
1 answer

Having a type field bitmeans that you need to use raw values ​​as a workaround when you insert / update this field.

, PDO , , bit 1:

DB::table('table')->insert(['bit_field' => 0]); // inserts 1
DB::table('table')->insert(['bit_field' => DB::raw(0)]); // inserts 0

tinyint, .

+11

Source: https://habr.com/ru/post/1569410/


All Articles