public function actionCreate()
{
$model=new events;
if(isset($_POST['events']))
{
$model->event_title = $_POST['events']['event_title'];
$model->event_description = $_POST['events']['event_description'];
$model->event_repeat_option = $_POST['events']['event_repeat_option'];
$model->event_start_date = date('Y-m-d H:i:s');
$model->event_end_date = date('Y-m-d H:i:s');
$model->user_id = yii::app()->user->getState('user_id');
$model->deal_id = "1";
$model->event_type = "1";
$model->event_creation_date = date('Y-m-d H:i:s');
if($model->save())
$this->redirect(array('view','id'=>$model->event_id));
}
}
插入多条记录?为什么?没有错误,没有错误......数据正在完美插入......但一次有多个记录。
我做了 Print_r($model->attributes);
Array
(
[event_status] => 1
[event_title] => test1
[event_description] => test1
[event_repeat_option] => test1
[event_start_date] => 2012-05-15 18:45:40
[event_end_date] => 2012-05-15 18:45:40
[user_id] => 3
[deal_id] => 1
[event_type] => 1
[event_creation_date] => 2012-05-15 18:45:40
[event_id] =>
)
...那里一切都很好,但仍然有一些错误...无法跟踪它。有什么建议吗?
模型属性
/**
* This is the model class for table "user_events".
*
* The followings are the available columns in table 'user_events':
* @property integer $event_id
* @property integer $user_id
* @property string $event_type
* @property integer $deal_id
* @property string $event_creation_date
* @property string $event_start_date
* @property string $event_end_date
* @property string $event_title
* @property string $event_description
* @property integer $event_repeat_option
* *
* The followings are the available model relations:
* @property Deals $deal
* @property RepeatOptions $eventRepeatOption
* @property Users $user */