【问题标题】:doctrine create query - parameter and value教义创建查询 - 参数和值
【发布时间】:2011-06-05 23:16:12
【问题描述】:

我在 mysql 中有表:

id |数字1 |数字2|数字 3|数字3|数字5|
1 | 6 | 3 | 4 | 2 | 1 |

$num = num2; $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: 绑定变量的数量与标记的数量不匹配

我做错了什么?

【问题讨论】:

  • $num 的值从何而来?看起来很可疑,我会谨慎处理您的操作。

标签: php sql symfony1 doctrine doctrine-1.2


【解决方案1】:

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

你应该试试

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-10-20
    • 2012-01-06
    • 1970-01-01
    • 2012-04-22
    相关资源
    最近更新 更多