本文整理汇总了PHP中GO\Base\Db\FindParams::getCriteria方法的典型用法代码示例。如果您正苦于以下问题:PHP FindParams::getCriteria方法的具体用法?PHP FindParams::getCriteria怎么用?PHP FindParams::getCriteria使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GO\Base\Db\FindParams
的用法示例。
在下文中一共展示了FindParams::getCriteria方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _findShares
/**
* Find all shared folders for the current user
*
* @param \GO\Base\Db\FindParams $findParams
* @return \GO\Base\Db\ActiveStatement
*/
private function _findShares($user_id)
{
$findParams = new \GO\Base\Db\FindParams();
$findParams->getCriteria()->addModel(Folder::model())->addCondition('visible', 1);
// ->addCondition('user_id', $user_id, '!=');
return Folder::model()->find($findParams);
}
示例2: beforeStoreStatement
protected function beforeStoreStatement(array &$response, array &$params, \GO\Base\Data\AbstractStore &$store, \GO\Base\Db\FindParams $storeParams)
{
if (empty($params['forContextMenu'])) {
$multiSel = new \GO\Base\Component\MultiSelectGrid('addresslist_filter', "GO\\Addressbook\\Model\\Addresslist", $store, $params, false);
$multiSel->formatCheckedColumn();
}
$storeParams->getCriteria()->addCondition('level', $params['permissionLevel'], '>=', 'go_acl');
}
示例3: _handleAdvancedQuery
/**
* FIXME: this method was copied from ModelController and never tested
* @param array $advancedQueryData the query data to be set to the store
* @param array $storeParams store params to be modied by advancedQuery
*/
private function _handleAdvancedQuery($advancedQueryData)
{
$advancedQueryData = is_string($advancedQueryData) ? json_decode($advancedQueryData, true) : $advancedQueryData;
$findCriteria = $this->_extraFindParams->getCriteria();
$criteriaGroup = \GO\Base\Db\FindCriteria::newInstance();
$criteriaGroupAnd = true;
for ($i = 0, $count = count($advancedQueryData); $i < $count; $i++) {
$advQueryRecord = $advancedQueryData[$i];
//change * into % wildcard
$advQueryRecord['value'] = isset($advQueryRecord['value']) ? str_replace('*', '%', $advQueryRecord['value']) : '';
if ($i == 0 || $advQueryRecord['start_group']) {
$findCriteria->mergeWith($criteriaGroup, $criteriaGroupAnd);
$criteriaGroupAnd = $advQueryRecord['andor'] == 'AND';
$criteriaGroup = \GO\Base\Db\FindCriteria::newInstance();
}
if (!empty($advQueryRecord['field'])) {
// Give the record a unique id, to enable the programmers to
// discriminate between advanced search query records of the same field
// type.
$advQueryRecord['id'] = $i;
// Check if current adv. search record should be handled in the standard
// manner.
$fieldParts = explode('.', $advQueryRecord['field']);
if (count($fieldParts) == 2) {
$field = $fieldParts[1];
$tableAlias = $fieldParts[0];
} else {
$field = $fieldParts[0];
$tableAlias = false;
}
if ($tableAlias == 't') {
$advQueryRecord['value'] = \GO::getModel($this->_modelClass)->formatInput($field, $advQueryRecord['value']);
} elseif ($tableAlias == 'cf') {
$advQueryRecord['value'] = \GO::getModel(\GO::getModel($this->_modelClass)->customfieldsModel())->formatInput($field, $advQueryRecord['value']);
}
$criteriaGroup->addCondition($field, $advQueryRecord['value'], $advQueryRecord['comparator'], $tableAlias, $advQueryRecord['andor'] == 'AND');
}
}
$findCriteria->mergeWith($criteriaGroup, $criteriaGroupAnd);
}
示例4: beforeStoreStatement
protected function beforeStoreStatement(array &$response, array &$params, \GO\Base\Data\AbstractStore &$store, \GO\Base\Db\FindParams $storeParams)
{
//SELECT * FROM cal_categories t
//LEFT JOIN go_acl ON (`t`.`acl_id` = go_acl.acl_id AND (go_acl.user_id=57 OR go_acl.group_id IN (2)))
//WHERE t.calendar_id = 0 AND go_acl.acl_id IS NOT NULL OR t.calendar_id=56
$groupIds = \GO\Base\Model\User::getGroupIds(\GO::user()->id);
$storeCriteria = $storeParams->getCriteria();
$joinUserGroupCriteria = \GO\Base\Db\FindCriteria::newInstance()->addCondition('user_id', \GO::user()->id, '=', 'go_acl', false)->addInCondition('group_id', $groupIds, 'go_acl', false);
$joinCriteria = \GO\Base\Db\FindCriteria::newInstance()->addCondition('acl_id', 'go_acl.acl_id', '=', 't', true, true)->mergeWith($joinUserGroupCriteria);
$storeParams->join('go_acl', $joinCriteria, 'go_acl', 'LEFT');
if (!empty($params['global_categories']) && !empty($params['calendar_id'])) {
$storeCriteria->addCondition('calendar_id', 0, '=', 't', false);
$storeCriteria->addCondition('acl_id', NULL, 'IS NOT', 'go_acl');
$storeCriteria->addCondition('calendar_id', $params['calendar_id'], '=', 't', false);
} elseif (!empty($params['calendar_id'])) {
$storeCriteria->addCondition('calendar_id', $params['calendar_id']);
} else {
$storeCriteria->addCondition('calendar_id', 0);
}
$storeParams->ignoreAcl();
return parent::beforeStoreStatement($response, $params, $store, $storeParams);
}
示例5: addSelectedToFindCriteria
/**
* Add the selected id's to the findCriteria. You use this in the other controller. eg. ContactController and not AddressbookController.
* Should be called in \GO\Base\Controller\AbstractModelController::beforeStoreStatement
* Will be called in \GO\Base\Data\DbStore::multiSelect()
* @param \GO\Base\Db\FindParams $findParams (object reference)
* @param string $columnName database column to match keys to
* @param string $tableAlias table alias of the column to match
* @param boolean $useAnd use AND when adding where condition
* @param boolean $useNot use NOT when adding where condition
*/
public function addSelectedToFindCriteria(\GO\Base\Db\FindParams &$findParams, $columnName, $tableAlias = 't', $useAnd = true, $useNot = false)
{
$selectedCount = count($this->selectedIds);
//ignore here. Permissions are checked in by _setSelectedIds.
if ($this->_checkPermissions) {
// $this->_validateSelection();
if ($selectedCount) {
$findParams->ignoreAcl();
}
}
if ($selectedCount) {
if ($selectedCount > 1) {
$tableName = "ms_" . $this->_requestParamName;
$findParams->getCriteria()->addInTemporaryTableCondition($tableName, $columnName, $this->selectedIds, $tableAlias, $useAnd, $useNot);
} else {
// $findParams->getCriteria()->addInCondition($columnName, $this->selectedIds, $tableAlias, $useAnd, $useNot);
$findParams->getCriteria()->addCondition($columnName, $this->selectedIds[0], $useNot ? '!=' : '=', $tableAlias, $useAnd);
}
}
// $findParams->debugSql();
// $this->_save();
}
示例6: checkFilterParams
private function checkFilterParams($show, \GO\Base\Db\FindParams $params)
{
// Check for a given filter on the statusses
if (!empty($show)) {
$statusCriteria = $params->getCriteria();
switch ($show) {
case 'today':
$start_time = mktime(0, 0, 0);
$end_time = \GO\Base\Util\Date::date_add($start_time, 1);
break;
case 'sevendays':
$start_time = mktime(0, 0, 0);
$end_time = \GO\Base\Util\Date::date_add($start_time, 7);
$show_completed = false;
break;
case 'overdue':
$start_time = 0;
$end_time = mktime(0, 0, 0);
$show_completed = false;
$show_future = false;
break;
case 'completed':
$start_time = 0;
$end_time = 0;
$show_completed = true;
//$show_future=false;
break;
case 'future':
$start_time = 0;
$end_time = 0;
$show_completed = false;
$show_future = true;
break;
case 'incomplete':
$start_time = 0;
$end_time = 0;
$show_completed = false;
break;
case 'active':
case 'portlet':
$start_time = 0;
$end_time = 0;
$show_completed = false;
$show_future = false;
break;
default:
// Nothing
break;
}
if (isset($show_completed)) {
if ($show_completed) {
$statusCriteria->addCondition('completion_time', 0, '>');
} else {
$statusCriteria->addCondition('completion_time', 0, '=');
}
}
if (!empty($start_time)) {
$statusCriteria->addCondition('due_time', $start_time, '>=');
}
if (!empty($end_time)) {
$statusCriteria->addCondition('due_time', $end_time, '<');
}
if (isset($show_future)) {
$now = \GO\Base\Util\Date::date_add(mktime(0, 0, 0), 1);
if ($show_future) {
$statusCriteria->addCondition('start_time', $now, '>=');
} else {
$statusCriteria->addCondition('start_time', $now, '<');
}
}
//$params->getCriteria()->mergeWith($statusCriteria);
// $params['criteriaObject']=$statusCriteria;
}
// // Check for a given filter on the categories
// if(isset($params['categoryFilter'])) {
// $categoryCriteria = \GO\Base\Db\FindCriteria::newInstance()
// ->addModel(\GO\Tasks\Model\Task::model(),'t');
//
// $categories = json_decode($params['categoryFilter'], true);
//
//// foreach($categories as $category)
//// $categoryCriteria->addCondition('category_id', $category, '=','t',false);
// //if(count($categories))
// $categoryCriteria->addInCondition('category_id', $categories,'t',false,false);
//
// if(isset($params['criteriaObject']))
// $params['criteriaObject']->mergeWith($categoryCriteria);
// else
// $params['criteriaObject'] = $categoryCriteria;
// }
return $params;
}
示例7: getTopLevelShares
/**
*
* @param \GO\Base\Db\FindParams $findParams
* @return \GO\Base\Db\ActiveStatement
*/
public function getTopLevelShares($findParams = false)
{
if (!$findParams) {
$findParams = new \GO\Base\Db\FindParams();
}
$findParams->joinRelation('sharedRootFolders')->ignoreAcl()->order('name', 'ASC')->limit(200);
$findParams->getCriteria()->addCondition('user_id', \GO::user()->id, '=', 'sharedRootFolders');
return $this->find($findParams);
}
示例8: beforeStoreStatement
protected function beforeStoreStatement(array &$response, array &$params, \GO\Base\Data\AbstractStore &$store, \GO\Base\Db\FindParams $storeParams)
{
$storeParams->getCriteria()->addCondition('user_id', \GO::user()->id);
return parent::beforeStoreStatement($response, $params, $store, $storeParams);
}