Zend modification. Adding MySQL FORCE INDEX hint

1.2k views Asked by At

I am trying to extend the Zend library in order to get queries like this one:

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

I am working arround with this Zend forum issue solution: http://framework.zend.com/issues/browse/ZF-7570

However I have a problem. Look at the code below.

$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

Some help?

2

There are 2 answers

0
Emilio Nicolás On BEST ANSWER

I am not pretty sure why, but if I remove the echo clause, fetchAll executes the right query...

So that's the answer, remove echo

0
Ezequiel On

In my opinion, the patch you are using is broken. If you check the source, it unsets the FORCE INDEX parts when creating the query the first time.

If you check it, $select->assemble() == $select->assemble() should give false.