doctrine create query - parameter and value
i have table in mysql:
id | num1 | num2| num 3| num3| num5| 1 | 6 | 3 | 4 | 2 | 1 |
$num = num2; $val = 2; $id = 2;
if i use
$q = Doctrine_Query::create()
-&开发者_Python百科gt;update('TABLE')
->set($num, '?', $val)
->where('id = ?', $id)
->execute();
work OK, but i use:
$q = Doctrine_Query::create()
->from('TABLE')
->where('id = ?', $id)
->andWhere($num ,' ?', $val)
->execute();
doesn't work. i have: 500 Internal Server Error
Doctrine_Connection_Mysql_Exception: SQLSTATE[HY093]: Invalid parameter number: number of bound variables does not match number of tokens
What am I doing wrong?
->andWhere($num ,' ?', $val)
is invalid.
your should try
->andWhere('num'.$num.' = ?', $val)
精彩评论