Condition Breaks My Subquery By Adding One Brace Too Much?

Hi all,

I have this query:

$currentIssue = Issue::model()->find(array(

   'condition'=>'number = (SELECT max(number) FROM issue))'


Which looks good to me and works in phpMyAdmin.

But Yii gives me this error:

SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ‘) LIMIT 1’ at line 1. The SQL statement executed was: SELECT * FROM issue t WHERE number = (SELECT max(number) FROM issue)) LIMIT 1

Somehow it is adding an additional brace at the end of the subquery.

When I remove the last brace from the condition (which looks wrong to me) the query is working. Can anyone explain to me why this is?



Wait, in the code you posted there are two opening braces and three closing.

Oh boy… I just didn’t see it… Thanks for pointing out this obvious mistake.