tags:

views:

155

answers:

1

Am looking for how I can extend the Zend_DB_Table below to accomodate a BETWEEN two dates syntax and LIMIT syntax

My current construct is

class Model_DbTable_Tablelist extends Zend_Db_Table_Abstract
{
    protected $_name = 'mytable';

    $select = $this->select()
                    ->setIntegrityCheck(false)
                    ->from('mytable',
                        array('MyCol1', 'MyDate'));

}

I want it extended to be equivalent to the query below

SELECT MyCol1,MyDate FROM mytable
WHERE MyDate BETWEEN '2008-04-03' AND '2009-01-02'
LIMIT 0,20

Any ideas?

+1  A: 

Regarding BETWEEN, this issue was reported on the Zend site - it appears to still be open. The workaround mentioned is to use something like

$this->where('MyDate > ?', '2008-04-03')->where('MyDate < ?', '2009-01-02');

Looks like you can use the "limit" method to add a LIMIT clause to your SQL, e.g.

->limit(0, 20);

Share and enjoy.

Bob Jarvis