Thursday, 15 August 2013

mysql - Yii CDbCriteria -



mysql - Yii CDbCriteria -

hollow have kind of query table select m.voterid, sum(jm.mark) marks m left bring together marks jm on jm.id = m.id jm.voterid in (1,2) grouping m.voterid

and don't understand how wright using cdbcriteria. table structute

`id` int(11) not null auto_increment, `voterid` int(11) not null, `votedid` int(11) not null, `mark` int(11) not null, `creation_date` timestamp not null default current_timestamp on update current_timestamp, primary key (`id`)

$criteria = new cdbcriteria(); $criteria->select = 'm.voterid, sum(jm.mark)'; $criteria->from = 'marks m'; $criteria->join = 'left bring together marks jm on jm.id = m.id'; $criteria->condition = 'jm.voterid in (1,2)'; $criteria->group = 'm.voterid';

mysql activerecord yii

No comments:

Post a Comment