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


PHP Builder::addSelect方法代码示例

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


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

示例1: apply

 public function apply(QueryBuilder $builder)
 {
     if (!$this->request->has('_DatatableQuery') || !isset($this->filters->idField)) {
         $builder->addSelect($this->db->raw('0 as _checked'));
         return $builder;
     }
     $this->filters->items[] = -1;
     if ($this->filters->checkedAll) {
         $builder->addSelect($this->db->raw('(case when ' . $this->filters->idField . ' IN (' . implode(',', $this->filters->items) . ') then 0 else 1 end) as _checked'));
         return $builder;
     }
     $builder->addSelect($this->db->raw('(case when ' . $this->filters->idField . ' IN (' . implode(',', $this->filters->items) . ') then 1 else 0 end) as _checked'));
     return $builder;
 }
开发者ID:girolando,项目名称:componente-animal,代码行数:14,代码来源:DataTableQuery.php

示例2: parseFullTextSearch

 /**
  * Parse the fulltext search parameter q
  *
  * @param  string $qParam
  * @param  array  $fullTextSearchColumns
  * @return void
  */
 protected function parseFullTextSearch($qParam, $fullTextSearchColumns)
 {
     if ($qParam == '') {
         //Add where that will never be true
         $this->query->whereRaw('0 = 1');
         return;
     }
     $fulltextType = Config::get('apihandler.fulltext');
     if ($fulltextType == 'native') {
         //Use pdo's quote method to be protected against sql-injections.
         //The usual placeholders unfortunately don't seem to work using AGAINST().
         $qParam = $this->query->getConnection()->getPdo()->quote($qParam);
         //Use native fulltext search
         $this->query->whereRaw('MATCH(' . implode(',', $fullTextSearchColumns) . ') AGAINST("' . $qParam . '" IN BOOLEAN MODE)');
         //Add the * to the selects because of the score column
         if (count($this->query->columns) == 0) {
             $this->query->addSelect('*');
         }
         //Add the score column
         $scoreColumn = Config::get('apihandler.fulltext_score_column');
         $this->query->addSelect($this->query->raw('MATCH(' . implode(',', $fullTextSearchColumns) . ') AGAINST("' . $qParam . '" IN BOOLEAN MODE) as `' . $scoreColumn . '`'));
     } else {
         $keywords = explode(' ', $qParam);
         //Use default php implementation
         $this->query->where(function ($query) use($fullTextSearchColumns, $keywords) {
             foreach ($fullTextSearchColumns as $column) {
                 foreach ($keywords as $keyword) {
                     $query->orWhere($column, 'LIKE', '%' . $keyword . '%');
                 }
             }
         });
     }
 }
开发者ID:marcelgwerder,项目名称:laravel-api-handler,代码行数:40,代码来源:Parser.php

示例3: checkQuerySelects

 protected function checkQuerySelects()
 {
     $selects = $this->query->getQuery()->columns;
     $tableSelect = $this->model->getTable() . '.*';
     if (empty($selects) || !in_array($tableSelect, $selects)) {
         $this->query->addSelect($tableSelect);
     }
 }
开发者ID:anlutro,项目名称:l4-core,代码行数:8,代码来源:RelationshipQueryJoiner.php

示例4: scopeJoinWithSelect

 /**
  * @param \Illuminate\Database\Query\Builder $query
  * @param string $table         join the table
  * @param string $one           joins first parameter
  * @param string|array|null $operatorOrCollumns    operator condition or collums list
  * @param string $two           joins two parameter
  * @param string $type          join type (left, right, '', etc)
  * @param bool|false $where     custom where condition
  * @param array $collumns       if you will not pass collumns, it will retreive the collumn listing. If you pass null
  * it will not get any data from the model.
  *
  * @return \Illuminate\Database\Query\Builder
  */
 public function scopeJoinWithSelect($query, $table, $one, $operatorOrCollumns, $two, $type = "left", $where = false, $collumns = array())
 {
     // if the operator collumns are in
     if (is_array($operatorOrCollumns) || is_null($operatorOrCollumns)) {
         $collumns = $operatorOrCollumns;
         $operatorOrCollumns = "=";
     }
     if (!is_null($collumns)) {
         // if there is no specific collumns, lets get all
         if (empty($collumns)) {
             $collumns = \Schema::getColumnListing($table);
         }
         // build the table values prefixed by the table to ensure unique values
         foreach ($collumns as $related_column) {
             $query->addSelect(new Expression("`{$table}`.`{$related_column}` AS `{$table}.{$related_column}`"));
         }
     }
     return $query->join($table, $one, $operatorOrCollumns, $two, $type, $where);
 }
开发者ID:OlegGetm,项目名称:abs_lara,代码行数:32,代码来源:ModelJoinTrait.php

示例5: filterScopes

 /**
  * Очень простая фильтрация скоупов.
  *
  * Если необходимо отфильтровать скоупы по id чему либо, обязательно нужно создать scope следующего вида.<br>
  * Пример:
  * * Ссылка для фильтрации - `catalog_id=*`
  * * Метод - `public function scopeCatalogId($int) {}`
  *
  * @return \Illuminate\Support\Collection
  */
 protected function filterScopes()
 {
     if (count($this->_request) > 0) {
         foreach ($this->_request as $scope => $value) {
             if (!empty($value)) {
                 //checked scope method for model
                 if (method_exists($this->_query->getModel(), 'scope' . camel_case($scope))) {
                     $this->_query->{camel_case($scope)}($value);
                 } else {
                     $values = explode(',', $value);
                     if (count($values) > 1) {
                         $this->filterSearch($scope, $values[0], '>');
                         $this->filterSearch($scope, $values[1], '<');
                     } else {
                         $this->filterSearch($scope, $value, 'like', '%', '%');
                     }
                 }
             }
         }
         $this->_query->addSelect($this->_query->getModel()->getTable() . '.*');
     }
     return $this->_request;
 }
开发者ID:assurrussa,项目名称:grid-view-vue,代码行数:33,代码来源:GridView.php

示例6: addSelect

 /**
  * Add a new select column to the query.
  *
  * @param array|mixed $column
  * @return $this 
  * @static 
  */
 public static function addSelect($column)
 {
     return \Illuminate\Database\Query\Builder::addSelect($column);
 }
开发者ID:satriashp,项目名称:tour,代码行数:11,代码来源:_ide_helper.php


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