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


PHP Model::select方法代碼示例

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


在下文中一共展示了Model::select方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: getByKey

 /**
  * Get local by key .
  *
  * @param $key
  * @param $locale
  * @param null $group
  * @return mixed
  */
 public function getByKey($key, $locale, $group = null)
 {
     $query = $this->source->select('languages.slug as locale', 'translations.*')->join('languages', 'languages.id', '=', 'translations.language_id')->where('languages.slug', $locale)->whereKey($key);
     if ($group) {
         $query->where('group', $group);
     }
     return $query->first();
 }
開發者ID:parfumix,項目名稱:laravel-translator,代碼行數:16,代碼來源:TranslationsRepository.php

示例2: getByCriteriaQuery

 /**
  * Generates the query builder object required for the get query requests.
  *
  * @param array $params
  * @return mixed
  */
 private function getByCriteriaQuery($params)
 {
     $query = $this->model->select(['*']);
     foreach ($params as $key => $value) {
         $query->where($key, '=', $value);
     }
     return $query;
 }
開發者ID:tectonic,項目名稱:laravel-localisation,代碼行數:14,代碼來源:EloquentTranslationRepository.php

示例3: buildQuery

 private function buildQuery()
 {
     $this->query = app(get_class($this->model));
     if (!empty($this->fields)) {
         $this->query = $this->query->select($this->fields);
     }
     if (!empty($this->relations)) {
         $this->relations = array_unique($this->relations);
         $this->query = $this->query->with($this->relations);
     }
     if (!empty($this->per_page)) {
         $this->query = $this->query->take($this->per_page);
     }
     if (count($this->conditions)) {
         foreach ($this->conditions as $condition) {
             $this->query = $this->query->where($condition['column'], $condition['operator'], $condition['value'], $condition['boolean']);
         }
     }
 }
開發者ID:bhutanio,項目名稱:laravel-utilities,代碼行數:19,代碼來源:DbRepository.php

示例4: buildBaseQuery

 /**
  * create a base eloquent search
  * 
  * @return null
  */
 public function buildBaseQuery()
 {
     $this->query = $this->model->select();
 }
開發者ID:hugorut,項目名稱:filterable,代碼行數:9,代碼來源:EloquentFilterBuilder.php

示例5: scopeToSubQuery

 /**
  * @param EloquentBuilder|QueryBuilder|Model $query
  * @param string $key
  * @param bool $returnExpression
  *
  * @return string
  */
 public function scopeToSubQuery($query, $key, $returnExpression = false)
 {
     $index = 0;
     $bindings = array();
     if (!Str::contains($key, '.')) {
         /** @var Model|BetterEloquentTrait $model */
         $model = $query->getModel();
         $key = $model->getField($key);
     }
     $sql = $query->select(array($key))->toSql();
     foreach ($query->getBindings() as $binding) {
         $bindings[] = is_array($binding) ? array_merge($bindings, $binding) : $binding;
     }
     while (Str::contains($sql, '?')) {
         $sql = $this->replaceFirst('?', $bindings[$index++], $sql);
     }
     $sql = "({$sql})";
     return $returnExpression ? new Expression($sql) : $sql;
 }
開發者ID:brazenvoid,項目名稱:better-eloquent,代碼行數:26,代碼來源:BetterEloquentTrait.php


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