Search code examples
mysqlzend-frameworkzend-db

Using FORCE INDEX with zend


I try to find how to translate the following MySQL query into Zend Db Table Select:

SELECT ColA,ColB,ColC
FROM MyTable
FORCE INDEX(ColA,ColB)
WHERE ColA = 'val0002'
AND ColB = 'val0045'

i try to use something like this:

$select = $dbTable->select()
            ->from('MyTable',array('ColA','ColB')
            ->forceIndex(array('ColA','ColB'))
            ->where("ColA = 'val0002'")
            ->where("ColB = 'val0045'");

I found " forceIndex(array('ColA','ColB')) " in a forum, but it does not work :(

and thank you for helping me :)


Solution

  • I think Zend_Db_Select doesn't support it yet. There seems to be an improvement request about it here: http://framework.zend.com/issues/browse/ZF-7570

    (The report comments contain some links to code that could be useful to you).

    Hope that helps,