2015-03-24

How to group WHERE clause in zf1

$db = $this->getAdapter();
$select = $db->select();
$select->from($this->_name);

$select->where('ip = ?', '120.0.0.1');
$select->orWhere('login = ?', 'test');

$subQuery = $select->getPart(Zend_Db_Select::WHERE);
$select->reset(Zend_Db_Select::WHERE);
$select->where(implode(' ', $subQuery));
$select->where('created_at = ?', date('Y-m-d'));

$res = $select->query()->fetchAll();
This will create sql with WHERE clause like as: "((ip = '127.0.0.1') OR (login = 'test')) AND (created_at = '2015-03-24')"

1 comment:

  1. Harrah's Casino Atlantic City - MapyRO
    Harrah's Hotel & Casino, Atlantic City. See 1313 강릉 출장마사지 traveler 대구광역 출장샵 reviews, 2026 candid photos, and great deals for Harrah's 춘천 출장마사지 Casino Atlantic City,  Rating: 3.5 · 부산광역 출장샵 ‎1313 논산 출장샵 reviews

    ReplyDelete