clausix95
clausix95

Reputation: 51

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()
->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?

Upvotes: 0

Views: 2987

Answers (1)

j_freyre
j_freyre

Reputation: 4738

->andWhere($num ,' ?', $val) is invalid.

your should try

->andWhere('num'.$num.' = ?', $val)

Upvotes: 2

Related Questions