Laravel 4雄辩地分配BIT值

编程入门 行业动态 更新时间:2024-10-07 12:23:11
本文介绍了Laravel 4雄辩地分配BIT值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我想使用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值

本文发布于:2023-11-11 08:36:41,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1577905.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:雄辩   分配   Laravel   BIT

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!