本文整理汇总了PHP中DbCommand::select方法的典型用法代码示例。如果您正苦于以下问题:PHP DbCommand::select方法的具体用法?PHP DbCommand::select怎么用?PHP DbCommand::select使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DbCommand
的用法示例。
在下文中一共展示了DbCommand::select方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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)
{
// Default query
$query->select('id, currentStep, totalSteps, status, type, description, settings, dateCreated')->from('tasks elements');
// Reset default element type query parts
$query->setJoin('');
$query->setWhere('1=1');
$query->setGroup('');
unset($query->params[':locale']);
unset($query->params[':elementsid1']);
if ($criteria->type) {
$query->andWhere(DbHelper::parseParam('type', $criteria->type, $query->params));
}
// Add search capabilities
if ($criteria->search) {
$query->andWhere(DbHelper::parseParam('description', '*' . $criteria->search . '*', $query->params));
$criteria->search = null;
}
}
示例2: modifyElementsQuery
/**
* Modify the elements query.
*
* @param DbCommand $query
* @param ElementCriteriaModel $criteria
*/
public function modifyElementsQuery(DbCommand $query, ElementCriteriaModel $criteria)
{
// Default query
$query->select('auditlog.id, auditlog.type, auditlog.userId, auditlog.origin, auditlog.before, auditlog.after, auditlog.status, auditlog.dateCreated, auditlog.dateUpdated')->from('auditlog auditlog');
// Reset default element type query parts
$query->setJoin('');
$query->setWhere('1=1');
$query->setGroup('');
unset($query->params[':locale']);
unset($query->params[':elementsid1']);
// Check for specific id
if (!empty($criteria->id)) {
$query->andWhere(DbHelper::parseParam('auditlog.id', $criteria->id, $query->params));
}
// Check type
if (!empty($criteria->type)) {
$query->andWhere(DbHelper::parseParam('auditlog.type', $criteria->type, $query->params));
}
// Check user id
if (!empty($criteria->userId)) {
$query->andWhere(DbHelper::parseParam('auditlog.userId', $criteria->userId, $query->params));
}
// Check origin
if (!empty($criteria->origin)) {
$query->andWhere(DbHelper::parseParam('auditlog.origin', $criteria->origin, $query->params));
}
// Check before
if (!empty($criteria->before)) {
$query->andWhere(DbHelper::parseParam('auditlog.before', $criteria->before, $query->params));
}
// Check after
if (!empty($criteria->after)) {
$query->andWhere(DbHelper::parseParam('auditlog.after', $criteria->after, $query->params));
}
// Check for status
if (!empty($criteria->status)) {
$query->andWhere(DbHelper::parseParam('auditlog.status', $criteria->status, $query->params));
}
// Dates
$this->applyDateCriteria($criteria, $query);
// Search
$this->applySearchCriteria($criteria, $query);
}
示例3: modifyElementsQuery
/**
* Cancel the elements query.
*
* @param DbCommand $query
* @param ElementCriteriaModel $criteria
*
* @return bool
*/
public function modifyElementsQuery(DbCommand $query, ElementCriteriaModel $criteria)
{
// Default query
$query->select('auditlog.id, auditlog.type, auditlog.userId, auditlog.origin, auditlog.before, auditlog.after, auditlog.status, auditlog.dateCreated, auditlog.dateUpdated')->from('auditlog auditlog');
// Reset default element type query parts
$query->setJoin('');
$query->setWhere('1=1');
$query->setGroup('');
unset($query->params[':locale']);
unset($query->params[':elementsid1']);
// Check for specific id
if (!empty($criteria->id)) {
$query->andWhere(DbHelper::parseParam('auditlog.id', $criteria->id, $query->params));
}
// Check type
if (!empty($criteria->type)) {
$query->andWhere(DbHelper::parseParam('auditlog.type', $criteria->type, $query->params));
}
// Check user id
if (!empty($criteria->userId)) {
$query->andWhere(DbHelper::parseParam('auditlog.userId', $criteria->userId, $query->params));
}
// Check origin
if (!empty($criteria->origin)) {
$query->andWhere(DbHelper::parseParam('auditlog.origin', $criteria->origin, $query->params));
}
// Check for date modified
if (!empty($criteria->modified)) {
$query->andWhere(DbHelper::parseDateParam('auditlog.dateUpdated', $criteria->modified, $query->params));
}
// Check before
if (!empty($criteria->before)) {
$query->andWhere(DbHelper::parseParam('auditlog.before', $criteria->before, $query->params));
}
// Check after
if (!empty($criteria->after)) {
$query->andWhere(DbHelper::parseParam('auditlog.after', $criteria->after, $query->params));
}
// Check for date from
if (!empty($criteria->from)) {
$query->andWhere(DbHelper::parseDateParam('auditlog.dateUpdated', '>= ' . DateTimeHelper::formatTimeForDb($criteria->from), $query->params));
}
// Check for date to
if (!empty($criteria->to)) {
$criteria->to->add(new DateInterval('PT23H59M59S'));
$query->andWhere(DbHelper::parseDateParam('auditlog.dateUpdated', '<= ' . DateTimeHelper::formatTimeForDb($criteria->to), $query->params));
}
// Check for type
if (!empty($criteria->type)) {
$query->andWhere(DbHelper::parseParam('auditlog.type', $criteria->type, $query->params));
}
// Check for status
if (!empty($criteria->status)) {
$query->andWhere(DbHelper::parseParam('auditlog.status', $criteria->status, $query->params));
}
// Search
if (!empty($criteria->search)) {
// Always perform a LIKE search
$criteria->search = '*' . $criteria->search . '*';
// Build conditions
$conditions = array('or', DbHelper::parseParam('auditlog.origin', $criteria->search, $query->params), DbHelper::parseParam('auditlog.before', $criteria->search, $query->params), DbHelper::parseParam('auditlog.after', $criteria->search, $query->params));
// Add to query
$query->andWhere($conditions, $query->params);
// Don't perform search logics after this
$criteria->search = null;
}
}