Zend Framework Complex Where Statement

前端 未结 4 1426
感动是毒
感动是毒 2021-01-07 03:04

This method is published as offical example

->where(\"price < $minimumPrice OR price > $maximumPrice\") is such method safe?

want to write it as ->where

4条回答
  •  暖寄归人
    2021-01-07 03:41

    If I have complex WHERE clauses I use the db adapters' ->quoteInto() method like:

    $where = '('
               . $dbAdapter->quoteInto('price1 < ?', $price1)
               . ' OR '
               . $dbAdapter->quoteInto('price1 > ?', $price1)
           . ')'
           . ' AND '
           . '('
               . $dbAdapter->quoteInto('price2 < ?', $price2)
               . ' OR '
               . $dbAdapter->quoteInto('price2 > ?', $price2)
           . ')'
           ;
    
    $select->where($where);
    

提交回复
热议问题