当前位置: 首页>>代码示例>>PHP>>正文


PHP SQLQuery::dataClass方法代码示例

本文整理汇总了PHP中SQLQuery::dataClass方法的典型用法代码示例。如果您正苦于以下问题:PHP SQLQuery::dataClass方法的具体用法?PHP SQLQuery::dataClass怎么用?PHP SQLQuery::dataClass使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在SQLQuery的用法示例。


在下文中一共展示了SQLQuery::dataClass方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: getQuery

 /**
  * Returns a SQL object representing the search context for the given
  * list of query parameters.
  *
  * @param array $searchParams Map of search criteria, mostly taked from $_REQUEST.
  *  If a filter is applied to a relationship in dot notation,
  *  the parameter name should have the dots replaced with double underscores,
  *  for example "Comments__Name" instead of the filter name "Comments.Name".
  * @param string|array $sort Database column to sort on. 
  *  Falls back to {@link DataObject::$default_sort} if not provided.
  * @param string|array $limit 
  * @param SQLQuery $existingQuery
  * @return SQLQuery
  */
 public function getQuery($searchParams, $sort = false, $limit = false, $existingQuery = null)
 {
     if ($existingQuery) {
         if (!$existingQuery instanceof DataList) {
             throw new InvalidArgumentException("existingQuery must be DataList");
         }
         if ($existingQuery->dataClass() != $this->modelClass) {
             throw new InvalidArgumentException("existingQuery's dataClass is " . $existingQuery->dataClass() . ", {$this->modelClass} expected.");
         }
         $query = $existingQuery;
     } else {
         $query = DataList::create($this->modelClass);
     }
     $query->limit($limit);
     $query->sort($sort);
     // hack to work with $searchParems when it's an Object
     $searchParamArray = array();
     if (is_object($searchParams)) {
         $searchParamArray = $searchParams->getVars();
     } else {
         $searchParamArray = $searchParams;
     }
     foreach ($searchParamArray as $key => $value) {
         $key = str_replace('__', '.', $key);
         if ($filter = $this->getFilter($key)) {
             $filter->setModel($this->modelClass);
             $filter->setValue($value);
             if (!$filter->isEmpty()) {
                 $filter->apply($query->dataQuery());
             }
         }
     }
     if ($this->connective != "AND") {
         throw new Exception("SearchContext connective '{$this->connective}' not supported after ORM-rewrite.");
     }
     return $query;
 }
开发者ID:,项目名称:,代码行数:51,代码来源:


注:本文中的SQLQuery::dataClass方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。