0

我在mysql中有表:

编号 | 数字1 | 数字2| 数字 3| 数字3| 数字5|
1 | 6 | 3 | 4 | 2 | 1 |

$数字=数字2;$val = 2; $id = 2;

如果我使用

$q = Doctrine_Query::create()
->update('TABLE')
->set($num, '?', $val)
->where('id = ?', $id)
->execute();

工作正常,但我使用:

            $q = Doctrine_Query::create()
          ->from('TABLE')
          ->where('id = ?', $id)
          ->andWhere($num ,' ?', $val)
          ->execute();

不起作用。我有:500 内部服务器错误

Doctrine_Connection_Mysql_Exception: SQLSTATE[HY093]: Invalid parameter number: 绑定变量数与令牌数不匹配

我究竟做错了什么?

4

1 回答 1

2

->andWhere($num ,' ?', $val) 无效

你应该试试

->andWhere('num'.$num.' = ?', $val)
于 2011-06-06T05:54:33.297 回答