Zend修改.添加 MySQL FORCE INDEX 提示



我正在尝试扩展Zend库以获取如下查询:

SELECT * FROM item i **force index(ix)** ORDER BY date LIMIT 100;

我正在研究这个Zend论坛问题解决方案:http://framework.zend.com/issues/browse/ZF-7570

但是我有一个问题。看看下面的代码。

$select->forceIndex('index');
echo $select->assemble();
     //  I get the right SELECT query with the force index hint
$this->fecthAll($select);
    //  The server execute a wrong SELECT query without the force index hint

一些帮助?

我不太确定为什么,但是如果我删除 echo 子句,fetchAll 会执行正确的查询......

所以这就是答案,删除回声

在我看来,您使用的补丁已损坏。如果检查源,则会在首次创建查询时取消设置 FORCE INDEX 部分。

如果你检查它,$select->assemble() == $select->assemble() 应该给出 false。

最新更新