本文整理汇总了PHP中Tinebase_Backend_Sql_Abstract::getDbCommand方法的典型用法代码示例。如果您正苦于以下问题:PHP Tinebase_Backend_Sql_Abstract::getDbCommand方法的具体用法?PHP Tinebase_Backend_Sql_Abstract::getDbCommand怎么用?PHP Tinebase_Backend_Sql_Abstract::getDbCommand使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Tinebase_Backend_Sql_Abstract
的用法示例。
在下文中一共展示了Tinebase_Backend_Sql_Abstract::getDbCommand方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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();
$dbCommand = $_backend->getDbCommand();
// 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);
}
}
示例2: 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']));
}
}
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 {
$gs->appendWhere(Zend_Db_Select::SQL_OR);
}
}