Yii项目知识搜集
2024-09-05 05:50:26
[['rId','advertiser_id','image_file'], 'unique','targetAttribute'=>['rId','advertiser_id','image_file'],'message'=>'重复插入数据'],//设置多个字段唯一
public static function getTableSchema() //设置字段的可变属性
{
$schema = parent::getTableSchema();
$schema->columns['age']->phpType = 'string';
return $schema;
}
public function behaviors()
{
return !empty($this->getDirtyAttributes())?[ //设置脏字段时最后更新时间变动
'timestamp' => [
'class' => TimestampBehavior::className(),
'attributes' => [
ActiveRecord::EVENT_BEFORE_INSERT => ['created_time', 'last_modified_time'],
ActiveRecord::EVENT_BEFORE_UPDATE => 'last_modified_time',
],
'value' => function() { return date('Y-m-d H:i:s'); },
],
]:(parent::behaviors());
}
最新文章
- 基于STSdb和fastJson的磁盘/内存缓存
- IOS-KVO&;KVC
- POJ 3180-The Cow Prom (图论-有向图强联通tarjan算法)
- MySQL数据库学习笔记(五)----MySQL字符串函数、日期时间函数
- cocos2d-x 制作系统公告
- cocos2dx游戏开发——微信打飞机学习笔记(十一)——GameOverScene的搭建
- poj3449Geometric Shapes
- CSS之弧形阴影
- threading模块
- excel取值
- hexo 适合前端 geek 的博客
- Harry Potter and the Prisoner of Azkaban
- C# 让程序自动以管理员身份运行
- Windows下安装Redmine-2.5.3
- java中强,软,弱,虚引用 以及WeakHahMap
- hdu 5445 多重背包
- JDK AtomicInteger 源码分析
- python第九十天----jquery
- QPS/TPS/并发量/系统吞吐量的概念
- StringBuffer类和String类(原文地址 : http://www.cnblogs.com/springcsc/archive/2009/12/03/1616330.html)