I have table with composite primary key ('service_id', 'action_id'). This table was implemented as many2many relationship between action and service.
I can delete some record in another table by simple primary key like that:
ModelClass::model()->deleteByPk( 5 );
How can I delete record with composite primary key?
ModelClass::model()->deleteByPk( ? );
See docs
For one record:
ModelClass::model()->deleteByPk(array('service_id'=>xxxx,'action_id'=>yyyy));
For multiple records:
ModelClass::model()->deleteByPk(array(
array('service_id'=>xxxx,'action_id'=>yyyy),
array('service_id'=>xxxx,'action_id'=>zzzz),
array('service_id'=>mmmm,'action_id'=>nnnn),
));
将元素作为键传递给数组
ModelClass::model()->deleteByPk(array('service_id'=>'value','action_id'=>'value'));
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.