Example #1
0
 /**
  * appends sql to given select statement
  *
  * @param Zend_Db_Select                $_select
  * @param Tinebase_Backend_Sql_Abstract $_backend
  */
 public function appendFilterSql($_select, $_backend)
 {
     // prepare value
     $value = (array) $this->_getDateValues($this->_operator, $this->_value);
     // quote field identifier
     $field = $this->_getQuotedFieldName($_backend);
     // db
     $this->_db = Tinebase_Core::getDb();
     // append query to select object
     foreach ((array) $this->_opSqlMap[$this->_operator]['sqlop'] as $num => $operator) {
         if (array_key_exists($num, $value)) {
             if (get_parent_class($this) === 'Tinebase_Model_Filter_Date' || in_array($this->_operator, array('isnull', 'notnull'))) {
                 $_select->where($field . $operator, $value[$num]);
             } else {
                 $value = Tinebase_Backend_Sql_Command::setDateValue($this->_db, $value[$num]);
                 $_select->where(Tinebase_Backend_Sql_Command::setDate($this->_db, $field) . $operator, $value);
             }
         } else {
             if (Tinebase_Core::isLogLevel(Zend_Log::DEBUG)) {
                 Tinebase_Core::getLogger()->debug(__METHOD__ . '::' . __LINE__ . ' No filter value found, skipping operator: ' . $operator);
             }
         }
     }
 }