Search code examples
zend-frameworkzend-db

Zend Framework Between Query


How can I write the following query in Zend Framework?

select * from hosted_plans where hp_id=15 and curdate() between discount_start_date and discount_end_date

In the query above the discount_start_date and discount_end_date columns are date fields in the table

Thanks in advance.


Solution

  • $query = $database->select ()
        ->from ('hosted_plans')
        ->where ('hp_id = ?', 15)
        ->where ('curdate() between discount_start_date and discount_end_date');
    

    $database being a Zend_Db_Adapter_Abstract descendant.