Yii DAO相关问题 [ 新手入门 ]
1.在保存成功后,提示lastInsertID未定义
$sql = 'INSERT INTO `{{Posts}}` (`excerpt`,`title`, `content`, `type`, `author`, `comment_status`, `post_password`, `modified`, `post_cate`, `cate_order`, `comment_count`) VALUES (:excerpt, :title, :content, :type, :author, :comment_status, :post_password, :modified, :post_cate, :cate_order, :comment_count)';
$command = Yii::app()->db->createCommand($sql);
$userId = Yii::app()->user->id;
$is_comment = Yii::app()->params['is_comment'];
$modified = time();
$cate_order = 0;
$comment_count = 0;
$command->bindParam(":excerpt",trim($_POST['Posts']['excerpt']));
$command->bindParam(":title",trim($_POST['Posts']['title']));
$command->bindParam(":content",CHtml::encode($_POST['Posts']['content']));
$command->bindParam(":type",$_POST['Posts']['type']);
$command->bindParam(":author",$userId);
$command->bindParam(":comment_status",$is_comment);
$command->bindParam(":post_password",md5($_POST['Posts']['post_password']));
$command->bindParam(":modified",$modified);
$command->bindParam(":post_cate",$_POST['Posts']['post_cate']);
$command->bindParam(":cate_order",$cate_order);
$command->bindParam(":comment_count",$comment_count);
if($command->execute())
$this->redirect(array('view','id'=>$command->lastInsertID));
2.DAO 保存的时候如何使用model里的rules验证?
共 9 条回复
-
ybt7755221 回复于 2012-08-23 14:35 举报
第一个搞定了,第二个真没集成model中的rules呢??
-
ybt7755221 回复于 2012-08-23 16:47 举报
怎么继承rules?
-
ybt7755221 回复于 2012-08-23 16:51 举报
想知道具体怎么继承model里的rules
-
-
ybt7755221 回复于 2012-08-24 14:38 举报
thank you 我试试
ybt7755221 山东烟台
注册时间:2011-07-26
最后登录:2018-02-08
在线时长:2小时37分
最后登录:2018-02-08
在线时长:2小时37分
- 粉丝1
- 金钱570
- 威望0
- 积分590