这是我的代码
$tablename = 'engine4_messages_recipients';
$columns = array('inbox_read'=>1);
$whereCondition = 'user_id=:user_id AND conversation_id=:conversation_id AND inbox_message_id!=NULL';
$whereConditionParams = array(':user_id'=>$user_id,':conversation_id'=>$conversation_id);
$command = Yii::app()->db->createCommand()->update($tablename,$columns,$whereCondition,$whereConditionParams);
DB table ::
CREATE TABLE IF NOT EXISTS `engine4_messages_recipients` (
`user_id` int(11) unsigned NOT NULL,
`conversation_id` int(11) unsigned NOT NULL,
`inbox_message_id` int(11) unsigned DEFAULT NULL,
`inbox_updated` datetime DEFAULT NULL,
`inbox_read` tinyint(1) DEFAULT NULL,
`inbox_deleted` tinyint(1) DEFAULT NULL,
`outbox_message_id` int(11) unsigned DEFAULT NULL,
`outbox_updated` datetime DEFAULT NULL,
`outbox_deleted` tinyint(1) DEFAULT NULL,
PRIMARY KEY (`user_id`,`conversation_id`),
KEY `INBOX_UPDATED` (`user_id`,`conversation_id`,`inbox_updated`),
KEY `OUTBOX_UPDATED` (`user_id`,`conversation_id`,`outbox_updated`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
-
engine4_messages_recipients
INSERT INTO engine4_messages_recipients
(user_id
,conversation_id
,inbox_message_id
,inbox_updated
,inbox_read
,inbox_deleted
,{{1 }},outbox_message_id
,outbox_updated
)价值观
(2,1,8,' 2014-09-18 12:24:16',0,0,7,' 2014-09-11 10:49:40',1 )
(3,1,7' 2014-09-11 10:49:40',0,0,8,' 2014-09-18 12:24:16',0 );
请帮帮我。 感谢
答案 0 :(得分:0)
试试这个
$tablename = 'engine4_messages_recipients';
$columns = array('inbox_read'=>1);
$whereCondition = 'user_id=:user_id AND conversation_id=:conversation_id AND inbox_message_id!=:inbox_message_id';
$whereConditionParams = array(':user_id'=>$user_id,':conversation_id'=>$conversation_id,':inbox_message_id'=>NULL);
$command = Yii::app()->db->createCommand()->update($tablename,$columns,$whereCondition,$whereConditionParams);