當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。