当前位置: 首页>>代码示例>>PHP>>正文


PHP Tinebase_Backend_Sql_Abstract::getAdapter方法代码示例

本文整理汇总了PHP中Tinebase_Backend_Sql_Abstract::getAdapter方法的典型用法代码示例。如果您正苦于以下问题:PHP Tinebase_Backend_Sql_Abstract::getAdapter方法的具体用法?PHP Tinebase_Backend_Sql_Abstract::getAdapter怎么用?PHP Tinebase_Backend_Sql_Abstract::getAdapter使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Tinebase_Backend_Sql_Abstract的用法示例。


在下文中一共展示了Tinebase_Backend_Sql_Abstract::getAdapter方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: appendFilterSql

 /**
  * appends sql to given select statement
  * 
  * @param  Zend_Db_Select                    $_select
  * @param  Tinebase_Backend_Sql_Abstract     $_backend
  * @throws Tinebase_Exception_NotFound
  */
 public function appendFilterSql($_select, $_backend)
 {
     $this->_options['ignoreAcl'] = TRUE;
     $this->_resolve();
     $quotedDisplayContainerIdentifier = $_backend->getAdapter()->quoteIdentifier('attendee.displaycontainer_id');
     $where = empty($this->_containerIds) ? Tinebase_Backend_Sql_Command::getFalseValue($_backend->getAdapter()) : $_select->getAdapter()->quoteInto($this->_getQuotedFieldName($_backend) . ' IN (?)', $this->_containerIds);
     $orWhere = empty($this->_containerIds) ? Tinebase_Backend_Sql_Command::getFalseValue($_backend->getAdapter()) : $_select->getAdapter()->quoteInto($quotedDisplayContainerIdentifier . ' IN (?)', $this->_containerIds);
     $_select->where($where);
     $_select->orWhere($orWhere);
 }
开发者ID:rodrigofns,项目名称:ExpressoLivre3,代码行数:17,代码来源:CalendarFilter.php

示例2: appendFilterSql

 /**
  * appends sql to given select statement
  *
  * @param  Zend_Db_Select                    $_select
  * @param  Tinebase_Backend_Sql_Abstract     $_backend
  */
 public function appendFilterSql($_select, $_backend)
 {
     $correlationName = Tinebase_Record_Abstract::generateUID(30);
     $db = $_backend->getAdapter();
     $_select->joinLeft(array($correlationName => $db->table_prefix . 'adb_list_m_role'), $db->quoteIdentifier($correlationName . '.contact_id') . ' = ' . $db->quoteIdentifier('addressbook.id'), array());
     $_select->where($db->quoteIdentifier($correlationName . '.list_role_id') . ' IN (?)', (array) $this->_value);
 }
开发者ID:ingoratsdorf,项目名称:Tine-2.0-Open-Source-Groupware-and-CRM,代码行数:13,代码来源:ListRoleMemberFilter.php

示例3: appendFilterSql

 /**
  * appends sql to given select statement
  *
  * @param Zend_Db_Select                $_select
  * @param Tinebase_Backend_Sql_Abstract $_backend
  */
 public function appendFilterSql($_select, $_backend)
 {
     $db = $_backend->getAdapter();
     // prepare value
     $value = $this->_value ? 1 : 0;
     if ($value) {
         // nothing to do -> show all contacts!
         if (Tinebase_Core::isLogLevel(Zend_Log::DEBUG)) {
             Tinebase_Core::getLogger()->debug(__METHOD__ . '::' . __LINE__ . ' Query all account contacts.');
         }
     } else {
         if (Tinebase_Core::isLogLevel(Zend_Log::DEBUG)) {
             Tinebase_Core::getLogger()->debug(__METHOD__ . '::' . __LINE__ . ' Only query visible and enabled account contacts.');
         }
         if (Tinebase_Core::getUser() instanceof Tinebase_Model_FullUser) {
             $where = '/* is no user */ ' . Tinebase_Backend_Sql_Command::getIfIsNull($db, $db->quoteIdentifier('accounts.id'), 'true', 'false') . ' OR /* is user */ (' . Tinebase_Backend_Sql_Command::getIfIsNull($db, $db->quoteIdentifier('accounts.id'), 'false', 'true') . ' AND ' . $db->quoteInto($db->quoteIdentifier('accounts.status') . ' = ?', 'enabled') . " AND " . '(' . $db->quoteInto($db->quoteIdentifier('accounts.visibility') . ' = ?', 'displayed') . ' OR ' . $db->quoteInto($db->quoteIdentifier('accounts.id') . ' = ?', Tinebase_Core::getUser()->getId()) . ')' . ")";
         } else {
             $where = '/* is no user */ ' . Tinebase_Backend_Sql_Command::getIfIsNull($db, $db->quoteIdentifier('accounts.id'), 'true', 'false') . ' OR /* is user */ (' . Tinebase_Backend_Sql_Command::getIfIsNull($db, $db->quoteIdentifier('accounts.id'), 'false', 'true') . ' AND ' . $db->quoteInto($db->quoteIdentifier('accounts.status') . ' = ?', 'enabled') . " AND " . $db->quoteInto($db->quoteIdentifier('accounts.visibility') . ' = ?', 'displayed') . ")";
         }
         $_select->where($where);
         $select = $_select instanceof Zend_Db_Select ? $_select : $_select->getSelect();
         $select = Tinebase_Backend_Sql_Abstract::traitGroup($db, $_backend->getTablePrefix(), $select);
         $_select instanceof Zend_Db_Select ? $_select = $select : $_select->setSelect($select);
         if (Tinebase_Core::isLogLevel(Zend_Log::DEBUG)) {
             Tinebase_Core::getLogger()->debug(__METHOD__ . '::' . __LINE__ . ' contacts query ' . $_select->assemble());
         }
     }
 }
开发者ID:rodrigofns,项目名称:ExpressoLivre3,代码行数:34,代码来源:ContactDisabledFilter.php

示例4: appendFilterSql

 /**
  * appends sql to given select statement
  *
  * @param Zend_Db_Select                $_select
  * @param Tinebase_Backend_Sql_Abstract $_backend
  */
 public function appendFilterSql($_select, $_backend)
 {
     if ($this->_value === self::VALUE_NOTSET) {
         return;
     }
     $action = $this->_opSqlMap[$this->_operator];
     $db = $_backend->getAdapter();
     // prepare value
     $value = $this->_value ? 1 : 0;
     if (!empty($this->_options['fields'])) {
         foreach ((array) $this->_options['fields'] as $fieldName) {
             $quotedField = $db->quoteIdentifier(strpos($fieldName, '.') === false ? $_backend->getTableName() . '.' . $fieldName : $fieldName);
             if ($value) {
                 $_select->where($quotedField . $action['sqlop'], $value);
             } else {
                 $_select->orwhere($quotedField . $action['sqlop'], $value);
             }
         }
     } else {
         if (!empty($this->_options['leftOperand'])) {
             $_select->where($this->_options['leftOperand'] . $action['sqlop'], $value);
         } else {
             $_select->where($this->_getQuotedFieldName($_backend) . $action['sqlop'], $value);
         }
     }
 }
开发者ID:ingoratsdorf,项目名称:Tine-2.0-Open-Source-Groupware-and-CRM,代码行数:32,代码来源:Bool.php

示例5: appendFilterSql2

 /**
  * appends sql to given select statement
  * 
  * @param  Zend_Db_Select                    $_select
  * @param  Tinebase_Backend_Sql_Abstract     $_backend
  * @throws Tinebase_Exception_NotFound
  */
 public function appendFilterSql2($_select, $_backend)
 {
     $this->_options['ignoreAcl'] = TRUE;
     $this->_resolve();
     $quotedDisplayContainerIdentifier = $_backend->getAdapter()->quoteIdentifier('attendee.displaycontainer_id');
     $_select->where($quotedDisplayContainerIdentifier . ' IN (?)', empty($this->_containerIds) ? " " : $this->_containerIds);
 }
开发者ID:bitExpert,项目名称:Tine-2.0-Open-Source-Groupware-and-CRM,代码行数:14,代码来源:CalendarFilter.php

示例6: appendFilterSql

 /**
  * appends sql to given select statement
  *
  * @param  Zend_Db_Select                    $_select
  * @param  Tinebase_Backend_Sql_Abstract     $_backend
  */
 public function appendFilterSql($_select, $_backend)
 {
     if ($this->_value === 'all') {
         $_select->where('1=1');
         return;
     }
     $gs = new Tinebase_Backend_Sql_Filter_GroupSelect($_select);
     $adapter = $_backend->getAdapter();
     $isExcept = strpos($this->_operator, 'Except') !== false;
     $sign = $isExcept ? '<>' : '=';
     //if (Tinebase_Core::isLogLevel(Zend_Log::DEBUG)) Tinebase_Core::getLogger()->debug(__METHOD__ . ' (' . __LINE__ . ') value: ' . print_r($this->_value, true));
     foreach ($this->_value as $attenderValue) {
         if (in_array($attenderValue['user_type'], array(Calendar_Model_Attender::USERTYPE_USER, Calendar_Model_Attender::USERTYPE_GROUPMEMBER))) {
             // @todo user_id might contain filter in the future -> get userids from adressbook controller with contact filter
             // transform CURRENTCONTACT
             $attenderValue['user_id'] = $attenderValue['user_id'] == Addressbook_Model_Contact::CURRENTCONTACT ? Tinebase_Core::getUser()->contact_id : $attenderValue['user_id'];
             $attendee = array(array('user_type' => Calendar_Model_Attender::USERTYPE_USER, 'user_id' => $attenderValue['user_id']));
             if (!$isExcept) {
                 $attendee[] = array('user_type' => Calendar_Model_Attender::USERTYPE_GROUPMEMBER, 'user_id' => $attenderValue['user_id']);
             }
         } else {
             if ($attenderValue['user_type'] == self::USERTYPE_MEMBEROF) {
                 // resolve group members
                 $group = Tinebase_Group::getInstance()->getGroupById($attenderValue['user_id']);
                 $attendee = array();
                 // fetch list only if list_id is not NULL, otherwise we get back an empty list object
                 if (!empty($group->list_id)) {
                     $contactList = Addressbook_Controller_List::getInstance()->get($group->list_id);
                     foreach ($contactList->members as $member) {
                         $attendee[] = array('user_type' => Calendar_Model_Attender::USERTYPE_USER, 'user_id' => $member);
                         if (!$isExcept) {
                             $attendee[] = array('user_type' => Calendar_Model_Attender::USERTYPE_GROUPMEMBER, 'user_id' => $member);
                         }
                     }
                 }
             } else {
                 $attendee = array($attenderValue);
             }
         }
         foreach ($attendee as $attender) {
             $gs->orWhere(($isExcept ? '' : $adapter->quoteInto($adapter->quoteIdentifier('attendee.user_type') . ' = ?', $attender['user_type']) . ' AND ') . $adapter->quoteInto($adapter->quoteIdentifier('attendee.user_id') . ' ' . $sign . ' ?', $attender['user_id']));
         }
     }
     if (substr($this->_operator, 0, 3) === 'not') {
         // join attendee to be excluded as a new column. records having this column NULL don't have the attendee
         $dname = 'attendee-not-' . Tinebase_Record_Abstract::generateUID(5);
         $_select->joinLeft(array($dname => $_backend->getTablePrefix() . 'cal_attendee'), $adapter->quoteIdentifier($dname . '.cal_event_id') . ' = ' . $adapter->quoteIdentifier($_backend->getTableName() . '.id') . ' AND ' . $gs->getSQL(), array($dname => $_backend->getDbCommand()->getAggregate($dname . '.id')));
         $_select->having($_backend->getDbCommand()->getAggregate($dname . '.id') . ' IS NULL');
     } else {
         if ($isExcept) {
             $dname = 'attendee-hasSome-' . Tinebase_Record_Abstract::generateUID(5);
             $_select->joinLeft(array($dname => $_backend->getTablePrefix() . 'cal_attendee'), $adapter->quoteIdentifier($dname . '.cal_event_id') . ' = ' . $adapter->quoteIdentifier($_backend->getTableName() . '.id') . ' AND ' . $gs->getSQL(), array($dname => $_backend->getDbCommand()->getAggregate($dname . '.id')));
             $_select->having($_backend->getDbCommand()->getAggregate($dname . '.id') . ' IS NOT NULL');
         } else {
             $gs->appendWhere(Zend_Db_Select::SQL_OR);
         }
     }
 }
开发者ID:ingoratsdorf,项目名称:Tine-2.0-Open-Source-Groupware-and-CRM,代码行数:64,代码来源:AttenderFilter.php

示例7: _appendGrantsFilter

 /**
  * append grants acl filter
  * 
  * @param Zend_Db_Select $select
  * @param Tinebase_Backend_Sql_Abstract $backend
  * @param Tinebase_Model_User $user
  */
 protected function _appendGrantsFilter($select, $backend, $user)
 {
     $db = $backend->getAdapter();
     $select->join(array($this->_aclTableName => SQL_TABLE_PREFIX . $this->_aclTableName), "{$db->quoteIdentifier($this->_aclTableName . '.record_id')} = {$db->quoteIdentifier($backend->getTableName() . '.id')}", array());
     Tinebase_Container::addGrantsSql($select, $user, $this->_requiredGrants, $this->_aclTableName);
     if (Tinebase_Core::isLogLevel(Zend_Log::TRACE)) {
         Tinebase_Core::getLogger()->trace(__METHOD__ . '::' . __LINE__ . ' $select after appending grants sql: ' . $select);
     }
 }
开发者ID:ingoratsdorf,项目名称:Tine-2.0-Open-Source-Groupware-and-CRM,代码行数:16,代码来源:GrantsFilterGroup.php

示例8: appendFilterSql

 /**
  * appends sql to given select statement
  *
  * @param Zend_Db_Select                $_select
  * @param Tinebase_Backend_Sql_Abstract $_backend
  */
 public function appendFilterSql($_select, $_backend)
 {
     $db = $_backend->getAdapter();
     // prepare value
     $value = $this->_value ? 1 : 0;
     if ($value) {
         // nothing to filter
     } else {
         $_select->where($db->quoteIdentifier($_backend->getTableName() . '.is_open') . ' = 1');
     }
 }
开发者ID:rodrigofns,项目名称:ExpressoLivre3,代码行数:17,代码来源:TimeaccountClosedFilter.php

示例9: appendFilterSql

 /**
  * appends custom filters to a given select object
  * 
  * @param  Zend_Db_Select                    $_select
  * @param  Tinebase_Backend_Sql_Abstract     $_backend
  * @return void
  * 
  * @todo replace custom filter!
  */
 public function appendFilterSql($_select, $_backend)
 {
     $this->_appendAclSqlFilter($_select);
     $db = $_backend->getAdapter();
     foreach ($this->_customData as $customData) {
         $value = $customData['value'];
         if ($customData['field'] == 'is_cleared') {
             $_select->joinLeft(array('ta' => $db->table_prefix . 'timetracker_timeaccount'), $db->quoteIdentifier('ta.id') . ' = ' . $db->quoteIdentifier('timetracker_timesheet.timeaccount_id'), array());
             $opStatus = $value ? '=' : '<>';
             $op = $value ? ' OR ' : ' AND ';
             $_select->where($db->quoteInto($customData['field'] . ' = ?', $value) . $op . $db->quoteInto('ta.status' . $opStatus . ' ? ', 'billed'));
         }
     }
 }
开发者ID:bitExpert,项目名称:Tine-2.0-Open-Source-Groupware-and-CRM,代码行数:23,代码来源:TimesheetFilter.php

示例10: appendFilterSql

 /**
  * appends sql to given select statement
  *
  * @param Zend_Db_Select                $_select
  * @param Tinebase_Backend_Sql_Abstract $_backend
  */
 public function appendFilterSql($_select, $_backend)
 {
     if (Tinebase_Core::isLogLevel(Zend_Log::DEBUG)) {
         Tinebase_Core::getLogger()->debug(__METHOD__ . '::' . __LINE__ . ' ' . 'Adding Path filter for: ' . $_backend->getModelName());
     }
     $this->_resolvePathIds();
     $idField = isset($this->_options['idProperty']) || array_key_exists('idProperty', $this->_options) ? $this->_options['idProperty'] : 'id';
     $db = $_backend->getAdapter();
     $qField = $db->quoteIdentifier($_backend->getTableName() . '.' . $idField);
     if (empty($this->_pathRecordIds)) {
         $_select->where('1=0');
     } else {
         $_select->where($db->quoteInto("{$qField} IN (?)", $this->_pathRecordIds));
     }
 }
开发者ID:ingoratsdorf,项目名称:Tine-2.0-Open-Source-Groupware-and-CRM,代码行数:21,代码来源:Path.php

示例11: appendFilterSql

 /**
  * appends sql to given select statement
  *
  * @param Tinebase_Backend_Sql_Filter_GroupSelect $_select
  * @param Tinebase_Backend_Sql_Abstract $_backend
  */
 public function appendFilterSql($_select, $_backend)
 {
     $db = $_backend->getAdapter();
     $value = $this->_value ? 1 : 0;
     if ($value) {
         // nothing to do -> show all lists!
         if (Tinebase_Core::isLogLevel(Zend_Log::DEBUG)) {
             Tinebase_Core::getLogger()->debug(__METHOD__ . '::' . __LINE__ . ' Query all lists.');
         }
     } else {
         if (Tinebase_Core::isLogLevel(Zend_Log::TRACE)) {
             Tinebase_Core::getLogger()->trace(__METHOD__ . '::' . __LINE__ . ' Only query visible lists.');
         }
         $_select->join(array('groupvisibility' => $db->table_prefix . 'groups'), $db->quoteIdentifier('groupvisibility.list_id') . ' = ' . $db->quoteIdentifier('addressbook_lists.id'), array());
         $_select->where($db->quoteIdentifier('groupvisibility.visibility') . ' = ?', 'displayed');
     }
 }
开发者ID:bitExpert,项目名称:Tine-2.0-Open-Source-Groupware-and-CRM,代码行数:23,代码来源:ListHiddenFilter.php

示例12: appendFilterSql

 /**
  * appends sql to given select statement
  * 
  * @param  Zend_Db_Select                    $_select
  * @param  Tinebase_Backend_Sql_Abstract     $_backend
  * @throws Tinebase_Exception_AccessDenied
  */
 public function appendFilterSql($_select, $_backend)
 {
     $db = $_backend->getAdapter();
     if ($this->_requiredGrants === NULL) {
         throw new Tinebase_Exception_AccessDenied('No grants have been defined.');
     }
     // it searches select columns
     // return an array where each element has 3 items: 0 - table, 1 - field/expression, 2 - alias
     $columns = $_select->getPart(Zend_Db_Select::COLUMNS);
     // it gets an array with expressions used in having clause
     $grants = array();
     foreach ($columns as $column) {
         if (!empty($column[2])) {
             $grants[$column[2]] = $column[1];
         }
     }
     // it uses into having clause expressions instead of aliases
     foreach ($this->_requiredGrants as $grant) {
         $_select->orHaving($db->quoteInto($db->quoteIdentifier($grants[$grant]) . ' = ?', 1, Zend_Db::INT_TYPE));
     }
 }
开发者ID:rodrigofns,项目名称:ExpressoLivre3,代码行数:28,代码来源:GrantFilter.php

示例13: appendFilterSql

 /**
  * appends sql to given select statement
  *
  * @param Zend_Db_Select                $_select
  * @param Tinebase_Backend_Sql_Abstract $_backend
  */
 public function appendFilterSql($_select, $_backend)
 {
     $db = $_backend->getAdapter();
     // prepare value
     $value = $this->_value ? 1 : 0;
     if ($value) {
         // nothing to do -> show all contacts!
         if (Tinebase_Core::isLogLevel(Zend_Log::DEBUG)) {
             Tinebase_Core::getLogger()->debug(__METHOD__ . '::' . __LINE__ . ' Query all account contacts.');
         }
     } else {
         if (Tinebase_Core::isLogLevel(Zend_Log::TRACE)) {
             Tinebase_Core::getLogger()->trace(__METHOD__ . '::' . __LINE__ . ' Only query visible and enabled (expired, blocked) account contacts.');
         }
         if (Tinebase_Core::getUser() instanceof Tinebase_Model_FullUser) {
             $where = '/* is no user */ ' . $db->quoteIdentifier('accounts.id') . ' IS NULL OR /* is user */ ' . '(' . $db->quoteIdentifier('accounts.id') . ' IS NOT NULL AND ' . $db->quoteInto($db->quoteIdentifier('accounts.status') . ' != ?', 'disabled') . " AND " . '(' . $db->quoteInto($db->quoteIdentifier('accounts.visibility') . ' = ?', 'displayed') . ' OR ' . $db->quoteInto($db->quoteIdentifier('accounts.id') . ' = ?', Tinebase_Core::getUser()->getId()) . ')' . ")";
         } else {
             $where = '/* is no user */ ' . $db->quoteIdentifier('accounts.id') . ' IS NULL OR /* is user */ ' . '(' . $db->quoteIdentifier('accounts.id') . ' IS NOT NULL AND ' . $db->quoteInto($db->quoteIdentifier('accounts.status') . ' != ?', 'disabled') . " AND " . $db->quoteInto($db->quoteIdentifier('accounts.visibility') . ' = ?', 'displayed') . ")";
         }
         $_select->where($where);
     }
 }
开发者ID:ingoratsdorf,项目名称:Tine-2.0-Open-Source-Groupware-and-CRM,代码行数:28,代码来源:ContactDisabledFilter.php

示例14: appendFilterSql

 /**
  * appends sql to given select statement
  *
  * @param  Zend_Db_Select                    $_select
  * @param  Tinebase_Backend_Sql_Abstract     $_backend
  */
 public function appendFilterSql($_select, $_backend)
 {
     if ($this->_value === 'all') {
         $_select->where('1=1');
         return;
     }
     $gs = new Tinebase_Backend_Sql_Filter_GroupSelect($_select);
     $adapter = $_backend->getAdapter();
     //if (Tinebase_Core::isLogLevel(Zend_Log::DEBUG)) Tinebase_Core::getLogger()->debug(__METHOD__ . ' (' . __LINE__ . ') value: ' . print_r($this->_value, true));
     foreach ($this->_value as $attenderValue) {
         if (in_array($attenderValue['user_type'], array(Calendar_Model_Attender::USERTYPE_USER, Calendar_Model_Attender::USERTYPE_GROUPMEMBER))) {
             // @todo user_id might contain filter in the future -> get userids from adressbook controller with contact filter
             // transform CURRENTCONTACT
             $attenderValue['user_id'] = $attenderValue['user_id'] == Addressbook_Model_Contact::CURRENTCONTACT ? Tinebase_Core::getUser()->contact_id : $attenderValue['user_id'];
             $attendee = array(array('user_type' => Calendar_Model_Attender::USERTYPE_USER, 'user_id' => $attenderValue['user_id']), array('user_type' => Calendar_Model_Attender::USERTYPE_GROUPMEMBER, 'user_id' => $attenderValue['user_id']));
         } else {
             if ($attenderValue['user_type'] == self::USERTYPE_MEMBEROF) {
                 // resolve group members
                 $group = Tinebase_Group::getInstance()->getGroupById($attenderValue['user_id']);
                 $attendee = array();
                 // fetch list only if list_id is not NULL, otherwise we get back an empty list object
                 if (!empty($group->list_id)) {
                     $contactList = Addressbook_Controller_List::getInstance()->get($group->list_id);
                     foreach ($contactList->members as $member) {
                         $attendee[] = array('user_type' => Calendar_Model_Attender::USERTYPE_USER, 'user_id' => $member);
                         $attendee[] = array('user_type' => Calendar_Model_Attender::USERTYPE_GROUPMEMBER, 'user_id' => $member);
                     }
                 }
             } else {
                 $attendee = array($attenderValue);
             }
         }
         foreach ($attendee as $attender) {
             $gs->orWhere($adapter->quoteInto($adapter->quoteIdentifier('attendee.user_type') . ' = ?', $attender['user_type']) . ' AND ' . $adapter->quoteInto($adapter->quoteIdentifier('attendee.user_id') . ' = ?', $attender['user_id']));
         }
     }
     $gs->appendWhere(Zend_Db_Select::SQL_OR);
 }
开发者ID:rodrigofns,项目名称:ExpressoLivre3,代码行数:44,代码来源:AttenderFilter.php

示例15: appendFilterSql

 /**
  * appends sql to given select statement
  *
  * @param Zend_Db_Select                $_select
  * @param Tinebase_Backend_Sql_Abstract $_backend
  */
 function appendFilterSql($_select, $_backend)
 {
     $months = array();
     $db = $_backend->getAdapter();
     $date = new Tinebase_DateTime();
     $format = 'Y-m';
     $like = FALSE;
     if ($this->_operator == 'within') {
         switch ($this->_value) {
             case 'monthThis':
                 $months = array($date->format($format));
                 break;
             case 'monthLast':
                 $months = array($date->subMonth(1)->format($format));
                 break;
             case 'beforeLastMonth':
                 $months = array($date->subMonth(2)->format($format));
                 break;
             case 'quarterThis':
                 $month = ceil(intval($date->format('m')) / 3) * 3;
                 $date->setDate($date->format('Y'), $month, 15);
                 $months = array($date->format($format), $date->subMonth(1)->format($format), $date->subMonth(1)->format($format));
                 break;
             case 'quarterLast':
                 $date->subMonth(3);
                 $month = ceil(intval($date->format('m')) / 3) * 3;
                 $date->setDate($date->format('Y'), $month, 15);
                 $months = array($date->format($format), $date->subMonth(1)->format($format), $date->subMonth(1)->format($format));
                 break;
             case 'beforeLastQuarter':
                 $date->subMonth(6);
                 $month = ceil(intval($date->format('m')) / 3) * 3;
                 $date->setDate($date->format('Y'), $month, 15);
                 $months = array($date->format($format), $date->subMonth(1)->format($format), $date->subMonth(1)->format($format));
                 break;
             case 'yearThis':
                 $like = $date->format('Y') . '-%';
                 break;
             case 'yearLast':
                 $date->subYear(1);
                 $like = $date->format('Y') . '-%';
                 break;
             default:
                 throw new Tinebase_Exception_InvalidArgument('The value for the within operator is not supported: ' . $this->_value);
         }
         if ($like) {
             $_select->where($db->quoteInto($this->_getQuotedFieldName($_backend) . " LIKE (?)", $like));
         } else {
             $_select->where($db->quoteInto($this->_getQuotedFieldName($_backend) . " IN (?)", $months));
         }
     } elseif ($this->_operator == 'equals') {
         if ('' == $this->_value) {
             $_select->where($this->_getQuotedFieldName($_backend) . " = '0000-00-00 00:00:00' OR " . $this->_getQuotedFieldName($_backend) . ' IS NULL');
         } else {
             $split = explode('-', $this->_value);
             if (!(strlen($this->_value) == 7 && (int) $split[0] > 1900 && (int) $split[1] > 0 && (int) $split[1] < 13)) {
                 throw new Tinebase_Exception_MonthFormat();
             }
             $_select->where($db->quoteInto($this->_getQuotedFieldName($_backend) . " = (?)", $this->_value));
         }
     } else {
         $date = new Tinebase_DateTime($this->_value);
         $date->setTimezone(Tinebase_Core::getUserTimezone());
         $dateString = $date->format('Y-m');
         switch ($this->_operator) {
             case 'before':
                 $_select->where($db->quoteInto($this->_getQuotedFieldName($_backend) . " < (?)", $dateString));
                 break;
             case 'after':
                 $_select->where($db->quoteInto($this->_getQuotedFieldName($_backend) . " > (?)", $dateString));
                 break;
             case 'before_or_equals':
                 $_select->where($db->quoteInto($this->_getQuotedFieldName($_backend) . " <= (?)", $dateString));
                 break;
             case 'after_or_equals':
                 $_select->where($db->quoteInto($this->_getQuotedFieldName($_backend) . " >= (?)", $dateString));
                 break;
             default:
                 throw new Tinebase_Exception_InvalidArgument('The operator ' . $this->_operator . ' is not supported for this filter!');
         }
     }
 }
开发者ID:ingoratsdorf,项目名称:Tine-2.0-Open-Source-Groupware-and-CRM,代码行数:88,代码来源:Month.php


注:本文中的Tinebase_Backend_Sql_Abstract::getAdapter方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。