Yii query to Mysql query config

Hi all,

I got this code in Yii:


 $comment = Comment::model()->with(array('issue'=> array(

               'condition'=>'project_id = 1')))->findAll(array( 

                      'order' => 't.create_time DESC', 'limit' => 2, ));

when I changed “‘limit’=>2” to “‘limit’ =>null”, then my web app run without any errors.

As I understand that if I changed those values the equivalent query will change to:


SELECT tbl_comment . * , tbl_issue . *    FROM tbl_comment

LEFT JOIN tbl_issue ON tbl_issue.id = tbl_comment.issue_id WHERE tbl_issue.project_id = 1

LIMIT null

I have tried this sql on mysql command line and the above query didn’t pass on mysql, but it did pass when I use the CODE above in Yii.

So, could you tell me why did this conflic occur? Thank you.

What do you mean by “didn’t pass”? Any errors?

My guess is that Yii is checking the value of the limit element, determining it is an invalid value and just leaving it out of the query. As for why you are getting an error when setting your limit to 2, I couldn’t tell you without seeing the error message.

look at your code in your code you have limit set to 2 and in sql your limit is set to null which is not valid sql