Yii Framework Forum: Where Not In Activerecord - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Where Not In Activerecord use not in activerecord Rate Topic: -----

#1 User is offline   serdar 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 1
  • Joined: 18-March 13

Posted 09 August 2013 - 07:49 PM

hello,
i want to update my table use to where not in.
$data['users']= array(5,13,28); //user id list
$groupMembersModel = new YumUsergroupMembers(); //activerecord model
$groupMembersModel::model()->updateAll(array(
'ugm_status'=>StatusEnums::STATUS_DELETED),
'ugm_group_id=:id and ugm_usr_id not in :userId',
array(':id'=>$data['groupId'], ':userId'=>$data['users']));
where is my error?
0

#2 User is offline   alirz23 

  • Master Member
  • PipPipPipPip
  • Yii
  • Group: Members
  • Posts: 677
  • Joined: 08-August 12
  • Location:Durban, South Africa

Posted 10 August 2013 - 03:52 AM

Hi I think this what you need

$data['users']= array(5,13,28); //user id list
YumUsergroupMembers::model()->updateAll(array(
		'ugm_status'=>StatusEnums::STATUS_DELETED
	),
	'ugm_group_id=:id AND ugm_usr_id NOT IN :userId',
	array(':id'=>$data['groupId'], ':userId'=>$data['users'])
);

0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users