当前位置: 首页>>代码示例>>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;未经允许,请勿转载。