當前位置: 首頁>>代碼示例>>PHP>>正文


PHP DbCommand::setWhere方法代碼示例

本文整理匯總了PHP中DbCommand::setWhere方法的典型用法代碼示例。如果您正苦於以下問題:PHP DbCommand::setWhere方法的具體用法?PHP DbCommand::setWhere怎麽用?PHP DbCommand::setWhere使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在DbCommand的用法示例。


在下文中一共展示了DbCommand::setWhere方法的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;
     }
 }
開發者ID:webremote,項目名稱:taskmanager,代碼行數:27,代碼來源:TaskManagerElementType.php

示例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);
 }
開發者ID:boboldehampsink,項目名稱:auditlog,代碼行數:49,代碼來源:AuditLogElementType.php

示例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;
     }
 }
開發者ID:webremote,項目名稱:auditlog,代碼行數:75,代碼來源:AuditLogElementType.php


注:本文中的DbCommand::setWhere方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。