Yii Rapid Application Development Hotshot Project 1, Develop a Comic Book Database, helps you to set up your Yii development environment and create a project in Yii. Project 2, Turn That DB into a Personal Mobile App, lets you to extend Yii to serve
本文实例讲述了yii实现model添加默认值的方法。分享给大家供大家参考,具体如下:
yii model 继承自CActiveRecord
有些字段可能不会出现在表单中,而需要在程序中加入。如订单编号,时间戳,操作的user_id等等。
以下二种方法:
1、在rules()方法中设定:
public function rules()
{
// NOTE: you should only define rules for those attributes that
// will rec