本文整理汇总了PHP中DbHelper::parseParam方法的典型用法代码示例。如果您正苦于以下问题:PHP DbHelper::parseParam方法的具体用法?PHP DbHelper::parseParam怎么用?PHP DbHelper::parseParam使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DbHelper
的用法示例。
在下文中一共展示了DbHelper::parseParam方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: modifyElementsQuery
public function modifyElementsQuery(DbCommand $query, ElementCriteriaModel $criteria)
{
$query->addSelect('
neoblocks.fieldId,
neoblocks.ownerId,
neoblocks.ownerLocale,
neoblocks.typeId,
neoblocks.collapsed
')->join('neoblocks neoblocks', 'neoblocks.id = elements.id')->leftJoin('neoblockstructures neoblockstructures', ['and', 'neoblockstructures.ownerId = neoblocks.ownerId', 'neoblockstructures.fieldId = neoblocks.fieldId', ['or', 'neoblockstructures.ownerLocale = neoblocks.ownerLocale', ['and', 'neoblockstructures.ownerLocale is null', 'neoblocks.ownerLocale is null']]])->leftJoin('structureelements structureelements', ['and', 'structureelements.structureId = neoblockstructures.structureId', 'structureelements.elementId = neoblocks.id']);
if ($criteria->fieldId) {
$query->andWhere(DbHelper::parseParam('neoblocks.fieldId', $criteria->fieldId, $query->params));
}
if ($criteria->ownerId) {
$query->andWhere(DbHelper::parseParam('neoblocks.ownerId', $criteria->ownerId, $query->params));
}
if ($criteria->ownerLocale) {
$query->andWhere(DbHelper::parseParam('neoblocks.ownerLocale', $criteria->ownerLocale, $query->params));
}
if ($criteria->typeId) {
$query->andWhere(DbHelper::parseParam('neoblocks.typeId', $criteria->typeId, $query->params));
} else {
if ($criteria->type) {
$query->join('neoblocktypes neoblocktypes', 'neoblocktypes.id = neoblocks.typeId');
$query->andWhere(DbHelper::parseParam('neoblocktypes.handle', $criteria->type, $query->params));
}
}
}
示例2: modifyElementsQuery
public function modifyElementsQuery(DbCommand $query, ElementCriteriaModel $criteria)
{
$query->addSelect('formbuilder_entries.formId, formbuilder_entries.title, formbuilder_entries.data')->join('formbuilder_entries formbuilder_entries', 'formbuilder_entries.id = elements.id');
if ($criteria->formId) {
$query->andWhere(DbHelper::parseParam('formbuilder_entries.formId', $criteria->formId, $query->params));
}
}
示例3: modifyElementsQuery
/**
* @inheritDoc IElementType::modifyElementsQuery()
*
* @param DbCommand $query
* @param ElementCriteriaModel $criteria
*
* @return mixed
*/
public function modifyElementsQuery(DbCommand $query, ElementCriteriaModel $criteria)
{
$query->addSelect('globalsets.name, globalsets.handle, globalsets.fieldLayoutId')->join('globalsets globalsets', 'globalsets.id = elements.id');
if ($criteria->handle) {
$query->andWhere(DbHelper::parseParam('globalsets.handle', $criteria->handle, $query->params));
}
}
示例4: modifyElementsQuery
public function modifyElementsQuery(DbCommand $query, ElementCriteriaModel $criteria)
{
$query->addSelect('submissions.formId')->join('formerly_submissions submissions', 'submissions.id = elements.id');
if ($criteria->formId) {
$query->andWhere(DbHelper::parseParam('submissions.formId', $criteria->formId, $query->params));
}
if ($criteria->form) {
$query->join('formerly_forms forms', 'forms.id = submissions.formId');
$query->andWhere(DbHelper::parseParam('formerly_forms.handle', $criteria->form, $query->params));
}
}
示例5: modifyElementsQuery
public function modifyElementsQuery(DbCommand $query, ElementCriteriaModel $criteria)
{
$query->addSelect('supertableblocks.fieldId, supertableblocks.ownerId, supertableblocks.ownerLocale, supertableblocks.typeId, supertableblocks.sortOrder')->join('supertableblocks supertableblocks', 'supertableblocks.id = elements.id');
if ($criteria->fieldId) {
$query->andWhere(DbHelper::parseParam('supertableblocks.fieldId', $criteria->fieldId, $query->params));
}
if ($criteria->ownerId) {
$query->andWhere(DbHelper::parseParam('supertableblocks.ownerId', $criteria->ownerId, $query->params));
}
if ($criteria->ownerLocale) {
$query->andWhere(DbHelper::parseParam('supertableblocks.ownerLocale', $criteria->ownerLocale, $query->params));
}
if ($criteria->type) {
$query->join('supertableblocktypes supertableblocktypes', 'supertableblocktypes.id = supertableblocks.typeId');
$query->andWhere(DbHelper::parseParam('supertableblocktypes.handle', $criteria->type, $query->params));
}
}
示例6: _applyFolderConditions
/**
* Applies WHERE conditions to a DbCommand query for folders.
*
* @param DbCommand $query
* @param FolderCriteriaModel $criteria
*
* @return null
*/
private function _applyFolderConditions($query, FolderCriteriaModel $criteria)
{
$whereConditions = array();
$whereParams = array();
if ($criteria->id) {
$whereConditions[] = DbHelper::parseParam('f.id', $criteria->id, $whereParams);
}
if ($criteria->sourceId) {
$whereConditions[] = DbHelper::parseParam('f.sourceId', $criteria->sourceId, $whereParams);
}
if ($criteria->parentId) {
$whereConditions[] = DbHelper::parseParam('f.parentId', $criteria->parentId, $whereParams);
}
if ($criteria->name) {
$whereConditions[] = DbHelper::parseParam('f.name', $criteria->name, $whereParams);
}
if (!is_null($criteria->path)) {
// This folder has a comma in it.
if (strpos($criteria->path, ',') !== false) {
// Escape the comma.
$condition = DbHelper::parseParam('f.path', str_replace(',', '\\,', $criteria->path), $whereParams);
$lastKey = key(array_slice($whereParams, -1, 1, true));
// Now un-escape it.
$whereParams[$lastKey] = str_replace('\\,', ',', $whereParams[$lastKey]);
} else {
$condition = DbHelper::parseParam('f.path', $criteria->path, $whereParams);
}
$whereConditions[] = $condition;
}
if (count($whereConditions) == 1) {
$query->where($whereConditions[0], $whereParams);
} else {
array_unshift($whereConditions, 'and');
$query->where($whereConditions, $whereParams);
}
}
示例7: modifyElementsQuery
/**
* @inheritDoc IElementType::modifyElementsQuery()
*
* @param DbCommand $query
* @param ElementCriteriaModel $criteria
*
* @return mixed
*/
public function modifyElementsQuery(DbCommand $query, ElementCriteriaModel $criteria)
{
$query->addSelect('assetfiles.sourceId, assetfiles.folderId, assetfiles.filename, assetfiles.kind, assetfiles.width, assetfiles.height, assetfiles.size, assetfiles.dateModified')->join('assetfiles assetfiles', 'assetfiles.id = elements.id');
if ($criteria->sourceId) {
$query->andWhere(DbHelper::parseParam('assetfiles.sourceId', $criteria->sourceId, $query->params));
}
if ($criteria->folderId) {
$query->andWhere(DbHelper::parseParam('assetfiles.folderId', $criteria->folderId, $query->params));
}
if ($criteria->filename) {
$query->andWhere(DbHelper::parseParam('assetfiles.filename', $criteria->filename, $query->params));
}
if ($criteria->kind) {
if (is_array($criteria->kind)) {
$query->andWhere(DbHelper::parseParam('assetfiles.kind', array_merge(array('or'), $criteria->kind), $query->params));
} else {
$query->andWhere(DbHelper::parseParam('assetfiles.kind', $criteria->kind, $query->params));
}
}
if ($criteria->width) {
$query->andWhere(DbHelper::parseParam('assetfiles.width', $criteria->width, $query->params));
}
if ($criteria->height) {
$query->andWhere(DbHelper::parseParam('assetfiles.height', $criteria->height, $query->params));
}
if ($criteria->size) {
$query->andWhere(DbHelper::parseParam('assetfiles.size', $criteria->size, $query->params));
}
}
示例8: modifyElementsQuery
/**
* Modifies an element query targeting elements of this type.
*
* @param DbCommand $query
* @param ElementCriteriaModel $criteria
* @return mixed
*/
public function modifyElementsQuery(DbCommand $query, ElementCriteriaModel $criteria)
{
// you must add the columns here when adding a new field
$query->addSelect('applications.formId, applications.firstName,
applications.lastName, applications.email, applications.status,
applications.phone, applications.dateCreated,')->join('applications applications', 'applications.id = elements.id');
if ($criteria->formId) {
$query->andWhere(DbHelper::parseParam('applications.formId', $criteria->formId, $query->params));
}
if ($criteria->form) {
$query->join('applications_forms applications_forms', 'applications_forms.id = applications.formId');
$query->andWhere(DbHelper::parseParam('applications_forms.handle', $criteria->form, $query->params));
}
if ($criteria->dateCreated) {
$query->andWhere(DbHelper::parseDateParam('entries.dateCreated', $criteria->dateCreated, $query->params));
}
}
示例9: modifyElementsQuery
/**
* Modifies an element query targeting elements of this type.
*
* @param DbCommand $query
* @param ElementCriteriaModel $criteria
* @return mixed
*/
public function modifyElementsQuery(DbCommand $query, ElementCriteriaModel $criteria)
{
$query->addSelect('events.calendarId, events.startDate, events.endDate')->join('events events', 'events.id = elements.id');
if ($criteria->calendarId) {
$query->andWhere(DbHelper::parseParam('events.calendarId', $criteria->calendarId, $query->params));
}
if ($criteria->calendar) {
$query->join('events_calendars events_calendars', 'events_calendars.id = events.calendarId');
$query->andWhere(DbHelper::parseParam('events_calendars.handle', $criteria->calendar, $query->params));
}
if ($criteria->startDate) {
$query->andWhere(DbHelper::parseDateParam('events.startDate', $criteria->startDate, $query->params));
}
if ($criteria->endDate) {
$query->andWhere(DbHelper::parseDateParam('events.endDate', $criteria->endDate, $query->params));
}
}
示例10: modifyElementsQuery
/**
* @inheritDoc IFieldType::modifyElementsQuery()
*
* @param DbCommand $query
* @param mixed $value
*
* @return null|false
*/
public function modifyElementsQuery(DbCommand $query, $value)
{
if ($value !== null) {
if ($this->defineContentAttribute()) {
$handle = $this->model->handle;
$query->andWhere(DbHelper::parseParam('content.' . craft()->content->fieldColumnPrefix . $handle, $value, $query->params));
} else {
return false;
}
}
}
示例11: _getUserIdsByGroupIds
/**
* @param $groupIds
*
* @return array
*/
private function _getUserIdsByGroupIds($groupIds)
{
$query = craft()->db->createCommand()->select('userId')->from('usergroups_users');
$query->where(DbHelper::parseParam('groupId', $groupIds, $query->params));
return $query->queryColumn();
}
示例12: buildElementsQuery
/**
* Preps a {@link DbCommand} object for querying for elements, based on a given element criteria.
*
* @param ElementCriteriaModel &$criteria The element criteria model
* @param string &$contentTable The content table that should be joined in. (This variable will
* actually get defined by buildElementsQuery(), and is passed by
* reference so whatever’s calling the method will have access to its
* value.)
* @param array &$fieldColumns Info about the content field columns being selected. (This variable
* will actually get defined by buildElementsQuery(), and is passed by
* reference so whatever’s calling the method will have access to its
* value.)
*
* @return DbCommand|false The DbCommand object, or `false` if the method was able to determine ahead of time that
* there’s no chance any elements are going to be found with the given parameters.
*/
public function buildElementsQuery(&$criteria = null, &$contentTable = null, &$fieldColumns = null)
{
if (!$criteria instanceof ElementCriteriaModel) {
$criteria = $this->getCriteria('Entry', $criteria);
}
$elementType = $criteria->getElementType();
if (!$elementType->isLocalized()) {
// The criteria *must* be set to the primary locale
$criteria->locale = craft()->i18n->getPrimarySiteLocaleId();
} else {
if (!$criteria->locale) {
// Default to the current app locale
$criteria->locale = craft()->language;
}
}
// Set up the query
// ---------------------------------------------------------------------
$query = craft()->db->createCommand()->select('elements.id, elements.type, elements.enabled, elements.archived, elements.dateCreated, elements.dateUpdated, elements_i18n.slug, elements_i18n.uri, elements_i18n.enabled AS localeEnabled')->from('elements elements')->join('elements_i18n elements_i18n', 'elements_i18n.elementId = elements.id')->where('elements_i18n.locale = :locale', array(':locale' => $criteria->locale))->group('elements.id');
if ($elementType->hasContent()) {
$contentTable = $elementType->getContentTableForElementsQuery($criteria);
if ($contentTable) {
$contentCols = 'content.id AS contentId';
if ($elementType->hasTitles()) {
$contentCols .= ', content.title';
}
// TODO: Replace this with a call to getFieldsForElementsQuery() in 3.0
$fieldColumns = $elementType->getContentFieldColumnsForElementsQuery($criteria);
foreach ($fieldColumns as $column) {
$contentCols .= ', content.' . $column['column'];
}
$query->addSelect($contentCols);
$query->join($contentTable . ' content', 'content.elementId = elements.id');
$query->andWhere('content.locale = :locale');
}
}
// Basic element params
// ---------------------------------------------------------------------
// If the 'id' parameter is set to any empty value besides `null`, don't return anything
if ($criteria->id !== null && empty($criteria->id)) {
return false;
}
if ($criteria->id) {
$query->andWhere(DbHelper::parseParam('elements.id', $criteria->id, $query->params));
}
if ($criteria->archived) {
$query->andWhere('elements.archived = 1');
} else {
$query->andWhere('elements.archived = 0');
if ($criteria->status) {
$statusConditions = array();
$statuses = ArrayHelper::stringToArray($criteria->status);
foreach ($statuses as $status) {
$status = StringHelper::toLowerCase($status);
// Is this a supported status?
if (in_array($status, array_keys($elementType->getStatuses()))) {
if ($status == BaseElementModel::ENABLED) {
$statusConditions[] = 'elements.enabled = 1';
} else {
if ($status == BaseElementModel::DISABLED) {
$statusConditions[] = 'elements.enabled = 0';
} else {
$elementStatusCondition = $elementType->getElementQueryStatusCondition($query, $status);
if ($elementStatusCondition) {
$statusConditions[] = $elementStatusCondition;
} else {
if ($elementStatusCondition === false) {
return false;
}
}
}
}
}
}
if ($statusConditions) {
if (count($statusConditions) == 1) {
$statusCondition = $statusConditions[0];
} else {
array_unshift($statusConditions, 'or');
$statusCondition = $statusConditions;
}
$query->andWhere($statusCondition);
}
}
}
//.........这里部分代码省略.........
示例13: modifyElementsQuery
/**
* Modifies an element query targeting elements of this type.
*
* @param DbCommand $query
* @param ElementCriteriaModel $criteria
* @return mixed
*/
public function modifyElementsQuery(DbCommand $query, ElementCriteriaModel $criteria)
{
$query->addSelect('shortlist_list.default, shortlist_list.userSlug, shortlist_list.public, shortlist_list.type, shortlist_list.ownerId, shortlist_list.ownerType')->join('shortlist_list shortlist_list', 'shortlist_list.id = elements.id');
if ($criteria->default) {
$query->andWhere(DbHelper::parseParam('shortlist_list.default', $criteria->default, $query->params));
}
if ($criteria->userSlug) {
$query->andWhere(DbHelper::parseParam('shortlist_list.userSlug', $criteria->userSlug, $query->params));
}
if ($criteria->public) {
$query->andWhere(DbHelper::parseParam('shortlist_list.public', $criteria->public, $query->params));
}
if ($criteria->ownerId) {
$query->andWhere(DbHelper::parseParam('shortlist_list.ownerId', $criteria->ownerId, $query->params));
}
if ($criteria->ownerType) {
$query->andWhere(DbHelper::parseParam('shortlist_list.ownerType', $criteria->ownerType, $query->params));
}
}
示例14: modifyElementsQuery
/**
* @inheritDoc IElementType::modifyElementsQuery()
*
* @param DbCommand $query
* @param ElementCriteriaModel $criteria
*
* @return mixed
*/
public function modifyElementsQuery(DbCommand $query, ElementCriteriaModel $criteria)
{
$query->addSelect('assetfiles.sourceId, assetfiles.folderId, assetfiles.filename, assetfiles.kind, assetfiles.width, assetfiles.height, assetfiles.size, assetfiles.dateModified')->join('assetfiles assetfiles', 'assetfiles.id = elements.id');
if (!empty($criteria->source)) {
$query->join('assetsources assetsources', 'assetfiles.sourceId = assetsources.id');
}
if ($criteria->sourceId) {
$query->andWhere(DbHelper::parseParam('assetfiles.sourceId', $criteria->sourceId, $query->params));
}
if ($criteria->source) {
$query->andWhere(DbHelper::parseParam('assetsources.handle', $criteria->source, $query->params));
}
if ($criteria->folderId) {
if ($criteria->includeSubfolders) {
$folders = craft()->assets->getAllDescendantFolders(craft()->assets->getFolderById($criteria->folderId));
$query->andWhere(DbHelper::parseParam('assetfiles.folderId', array_keys($folders), $query->params));
} else {
$query->andWhere(DbHelper::parseParam('assetfiles.folderId', $criteria->folderId, $query->params));
}
}
if ($criteria->filename) {
$query->andWhere(DbHelper::parseParam('assetfiles.filename', $criteria->filename, $query->params));
}
if ($criteria->kind) {
if (is_array($criteria->kind)) {
$query->andWhere(DbHelper::parseParam('assetfiles.kind', array_merge(array('or'), $criteria->kind), $query->params));
} else {
$query->andWhere(DbHelper::parseParam('assetfiles.kind', $criteria->kind, $query->params));
}
}
if ($criteria->width) {
$query->andWhere(DbHelper::parseParam('assetfiles.width', $criteria->width, $query->params));
}
if ($criteria->height) {
$query->andWhere(DbHelper::parseParam('assetfiles.height', $criteria->height, $query->params));
}
if ($criteria->size) {
$query->andWhere(DbHelper::parseParam('assetfiles.size', $criteria->size, $query->params));
}
}
示例15: _subparseRelationParam
//.........这里部分代码省略.........
$blockTypeFieldIds = array();
// Searching by a specific block type field?
if (isset($fieldHandleParts[1])) {
// There could be more than one block type field with this handle, so we must loop through all
// of the block types on this Matrix field
$blockTypes = craft()->matrix->getBlockTypesByFieldId($fieldModel->id);
foreach ($blockTypes as $blockType) {
foreach ($blockType->getFields() as $blockTypeField) {
if ($blockTypeField->handle == $fieldHandleParts[1]) {
$blockTypeFieldIds[] = $blockTypeField->id;
break;
}
}
}
if (!$blockTypeFieldIds) {
continue;
}
}
if (isset($relCriteria['sourceElement'])) {
$this->_joinSourcesCount++;
$this->_joinTargetMatrixBlocksCount++;
$sourcesAlias = 'sources' . $this->_joinSourcesCount;
$targetMatrixBlocksAlias = 'target_matrixblocks' . $this->_joinTargetMatrixBlocksCount;
$relationsJoinConditions = array('and', $sourcesAlias . '.targetId = elements.id');
$relationsJoinParams = array();
if (!empty($relCriteria['sourceLocale'])) {
$this->_sourceLocaleParamCount++;
$sourceLocaleParam = ':sourceLocale' . $this->_sourceLocaleParamCount;
$relationsJoinConditions[] = array('or', $sourcesAlias . '.sourceLocale is null', $sourcesAlias . '.sourceLocale = ' . $sourceLocaleParam);
$relationsJoinParams[$sourceLocaleParam] = $relCriteria['sourceLocale'];
}
$query->leftJoin('relations ' . $sourcesAlias, $relationsJoinConditions, $relationsJoinParams);
$query->leftJoin('matrixblocks ' . $targetMatrixBlocksAlias, $targetMatrixBlocksAlias . '.id = ' . $sourcesAlias . '.sourceId');
$condition = array('and', DbHelper::parseParam($targetMatrixBlocksAlias . '.ownerId', $relElementIds, $query->params), $targetMatrixBlocksAlias . '.fieldId = ' . $fieldModel->id);
if ($blockTypeFieldIds) {
$condition[] = DbHelper::parseParam($sourcesAlias . '.fieldId', $blockTypeFieldIds, $query->params);
}
} else {
$this->_joinSourceMatrixBlocksCount++;
$sourceMatrixBlocksAlias = 'source_matrixblocks' . $this->_joinSourceMatrixBlocksCount;
$matrixBlockTargetsAlias = 'matrixblock_targets' . $this->_joinSourceMatrixBlocksCount;
$relationsJoinConditions = array('and', $matrixBlockTargetsAlias . '.sourceId = ' . $sourceMatrixBlocksAlias . '.id');
$relationsJoinParams = array();
if (!empty($relCriteria['sourceLocale'])) {
$this->_sourceLocaleParamCount++;
$sourceLocaleParam = ':sourceLocale' . $this->_sourceLocaleParamCount;
$relationsJoinConditions[] = array('or', $matrixBlockTargetsAlias . '.sourceLocale is null', $matrixBlockTargetsAlias . '.sourceLocale = ' . $sourceLocaleParam);
$relationsJoinParams[$sourceLocaleParam] = $relCriteria['sourceLocale'];
}
$query->leftJoin('matrixblocks ' . $sourceMatrixBlocksAlias, $sourceMatrixBlocksAlias . '.ownerId = elements.id');
$query->leftJoin('relations ' . $matrixBlockTargetsAlias, $relationsJoinConditions, $relationsJoinParams);
$condition = array('and', DbHelper::parseParam($matrixBlockTargetsAlias . '.targetId', $relElementIds, $query->params), $sourceMatrixBlocksAlias . '.fieldId = ' . $fieldModel->id);
if ($blockTypeFieldIds) {
$condition[] = DbHelper::parseParam($matrixBlockTargetsAlias . '.fieldId', $blockTypeFieldIds, $query->params);
}
}
$conditions[] = $condition;
} else {
$normalFieldIds[] = $fieldModel->id;
}
}
}
// If there were no fields, or there are some non-Matrix fields, add the normal relation condition. (Basically,
// run this code if the rel criteria wasn't exclusively for Matrix.)
if (empty($relCriteria['field']) || $normalFieldIds) {
if (isset($relCriteria['sourceElement'])) {