Zend_Db:准备语句不处理参数

我正在使用Zend_Db和Pdo_Mysql驱动程序。 此查询未给出任何结果:</ p>

  $ s = $ db-&gt; prepare('SELECT ET.id 
FROM elementTypes AS ET,language AS L1
WHERE L1.strId = ET.dispName AND L1.language =?');
$ s-&gt; execute(array(2));

pr($ s-&gt; fetchAll());
</ code> </ pre>

如果我对参数进行硬编码,则返回预期的行。</ p>

这里发生了什么? </ p>

编辑</ strong>:这是一个简化的脚本,查询更简单: http://pastebin.com/84UtcGGZ </ p>

Eidt 2:</ strong>我进一步钻了下来,发现问题出在 PDO并将ENUMS与整数进行比较</ strong>。 看到这个问题: PDO无法使用整数来比较mysql ENUM 准备好的陈述
如果您知道如何使其在Zend_Db上运行的任何修复/解决方法,请发布! :)** </ p>
</ div>

展开原文

原文

I am using Zend_Db with the Pdo_Mysql driver. This query does not give any results:

$s = $db->prepare('SELECT ET.id
                    FROM elementTypes AS ET, language AS L1 
                    WHERE L1.strId = ET.dispName AND L1.language = ?');
$s->execute(array(2));                                          
pr($s->fetchAll());

If I hardcode the parameter, the expected rows are returned.

What is going on here?

Edit: Here's a stripped down script with even simpler queries: http://pastebin.com/84UtcGGZ

Eidt 2: I have drilled further down and found that the problem lies with PDO and comparing ENUMS with ints. See this question: PDO cannot compare mysql ENUM using integers in prepared statements If you know any fixes/workarounds on how to get this to work on Zend_Db, please post! :)**

1个回答



语句不起作用的原因是L1.language是一个ENUM,你无法在Zend_Db / PDO中将ENUMS与整数进行比较 。</ p>

为什么以及如何避免这种情况在这个问题中得到了解释: PDO无法在预准备语句中使用整数来比较mysql ENUM </ p>
</ div>

展开原文

原文

The reason why the statement does not work is that L1.language is an ENUM, and you cannot compare ENUMS with integers in Zend_Db / PDO.

Why, and how to avoid this is explaied in this question: PDO cannot compare mysql ENUM using integers in prepared statements

立即提问
相关内容推荐