Issue
How can I find max value of one column in database by Yii Active Record?
I can do it by pure sql and createCommand method,but I wanna do it by Active Record and CDbCriteria class.is there any way to do it?
Solution
You will want to change the select criteria as follows.
$model = new Model;
$criteria=new CDbCriteria;
$criteria->select='max(column) AS maxColumn';
$row = $model->model()->find($criteria);
$somevariable = $row['maxColumn'];
Reference:
Answered By - Stephen305
0 Comments:
Post a Comment
Note: Only a member of this blog may post a comment.