Laravel 4雄辩地分配BIT值 [英] Laravel 4 Eloquent assign BIT values
问题描述
我想使用Eloquent在mySql中设置 BIT
数据类型的提交。
I want to set a filed with BIT
data type in mySql using Eloquent.
$i = new Step;
$i->active = 'b0';
$i->save();
但是,活动
$ c> 1 ,我也试过:
But the active
filed is 1
, I also tried:
$i->active = "b'0'";
$i->active = '0';
$i->active = false;
...
只需要运行这样的东西:
Simply I want to run something like this:
INSERT INTO `steps` (`active`) VALUES (b'0')
推荐答案
谈论活动
字段:
如果要使用活动
和无效
标记活动
和不活动状态(即用户模型),则可以使用
tinyint
数据类型。 / p>
Talking about active
field:
If you want to use active
and inactive
for flagging active
and inactive
state of any record (i.e. user model) then you may use tinyint
data type.
Bool,Boolean:这些类型是TINYINT(1)的同义词。
零的值被认为是false。非零值被认为是真实的。
Bool, Boolean: These types are synonyms for TINYINT(1). A value of zero is considered false. Non-zero values are considered true.
软删除
Laravel为表格中的 deleted_at
字段提供了这种操作的内置机制,该字段称为软删除。阅读更多关于这里给出的手册链接,它很容易实现和使用。
Soft Deleting
Also, Laravel provides built-in mechanism for this kind of operation using a deleted_at
field in the table which is known as soft delete. Read more on the manual link given here, it's easy to implement and use.
这篇关于Laravel 4雄辩地分配BIT值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!