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


PHP Query\Builder类代码示例

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


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

示例1: applyFilterConstraint

 /**
  * @param QueryBuilder $builder
  * @param $data
  *
  * @return void
  */
 public function applyFilterConstraint(QueryBuilder $builder, $data)
 {
     if (empty($data)) {
         return;
     }
     $builder->whereIn($this->relation->getForeignKey(), explode(',', $data));
 }
开发者ID:guratr,项目名称:cruddy,代码行数:13,代码来源:BelongsTo.php

示例2: selectWhereIn

 private function selectWhereIn($keys, Builder $query)
 {
     $results = [];
     foreach (array_chunk($keys, 500) as $chunk) {
         $results = array_merge($results, $this->connection->table($this->connection->raw("({$query->toSql()}) as query"))->whereIn("__key", $chunk)->get());
     }
     return collect($results)->keyBy("__key")->toArray();
 }
开发者ID:ifgroup,项目名称:merger,代码行数:8,代码来源:Merger.php

示例3: processInsertGetId

 /**
  * Process an "insert get ID" query.
  *
  * @param \Illuminate\Database\Query\Builder $query        	
  * @param string $sql        	
  * @param array $values        	
  * @param string $sequence        	
  * @return int
  */
 public function processInsertGetId(Builder $query, $sql, $values, $sequence = null)
 {
     $results = $query->getConnection()->selectFromWriteConnection($sql, $values);
     $sequence = $sequence ?: 'id';
     $result = (array) $results[0];
     $id = $result[$sequence];
     return is_numeric($id) ? (int) $id : $id;
 }
开发者ID:ngitimfoyo,项目名称:Nyari-AppPHP,代码行数:17,代码来源:PostgresProcessor.php

示例4: processInsertGetId

 /**
  * Process an "insert get ID" query.
  *
  * @param  \Illuminate\Database\Query\Builder  $query
  * @param  string  $sql
  * @param  array   $values
  * @param  string  $sequence
  * @return int
  */
 public function processInsertGetId(Builder $query, $sql, $values, $sequence = null)
 {
     $results = $query->getConnection()->select($sql, $values);
     $sequence = $sequence ?: 'id';
     $result = (array) $results[0];
     return (int) $result[$sequence];
 }
开发者ID:Thomvh,项目名称:turbine,代码行数:16,代码来源:PostgresProcessor.php

示例5: scopeCategory

 /**
  * Eloquent Scope for tag categories.
  * 
  * @param \Illuminate\Database\Query\Builder $query
  * @param string                             $category
  *
  * @return \Illuminate\Database\Query\Builder
  */
 public function scopeCategory($query, $category)
 {
     if (!is_null($category)) {
         return $query->where('category', '=', $category);
     }
     return $query;
 }
开发者ID:displore,项目名称:tags,代码行数:15,代码来源:Tag.php

示例6: scopeFindByRequest

 /**
  * Find by conditions in request
  *
  * @param Builder $query
  * @param array|null $request
  * @return \Illuminate\Database\Query\Builder
  */
 public function scopeFindByRequest($query, $request = NULL)
 {
     if (is_null($request)) {
         $request = Input::all();
     }
     $findable = isset($this->findable) ? $this->findable : [];
     foreach ($request as $field => $value) {
         if (!in_array($field, $findable)) {
             continue;
         }
         if ($field == 'tag') {
             if (isset($request['tag_search']) && $request['tag_search'] == 'any') {
                 $query->withAnyTag($value);
             } else {
                 $query->withAllTags($value);
             }
             continue;
         }
         if (is_array($value)) {
             $query->whereIn($field, $value);
         } elseif (is_scalar($value)) {
             $query->where($field, '=', $value);
         }
     }
 }
开发者ID:xEdelweiss,项目名称:my-perfect-back-end,代码行数:32,代码来源:FindByRequestTrait.php

示例7: scopeOfType

 /**
  * @param \Illuminate\Database\Query\Builder $query
  * @param string                             $type
  *
  * @return \Illuminate\Database\Query\Builder
  * @throws \Exception
  */
 public function scopeOfType($query, $type = 'image')
 {
     if (!in_array($type, ['plain', 'image', 'audio', 'video', 'application'])) {
         throw new \Exception();
     }
     return $query->where('mime', 'like', $type . '/%');
 }
开发者ID:audithsoftworks,项目名称:basis,代码行数:14,代码来源:File.php

示例8: execute

 public function execute(Builder $query)
 {
     $isWhere = false;
     $count = 0;
     foreach ($this->getValuesIterator() as $where) {
         $operator = $where->getOperator();
         if (array_key_exists($operator, WhereValidator::$especial_operator)) {
             $method = $where->getOperatorValue();
             switch ($method) {
                 case WhereValidator::$especial_operator['isNull']:
                 case WhereValidator::$especial_operator['isNotNull']:
                     $query->{$method}($where->getName());
                     break;
                 case WhereValidator::$especial_operator['between']:
                 case WhereValidator::$especial_operator['in']:
                     $query->{$method}($where->getName(), $where->getValue());
                     break;
             }
             continue;
         } else {
             if ($where->getOperatorValue() == WhereValidator::$operator['like']) {
                 $value = '%' . $where->getValue() . '%';
             } else {
                 $value = $where->getValue();
             }
         }
         $query->where($where->getName(), $where->getOperatorValue(), $value);
     }
     return $query;
 }
开发者ID:brenodouglas,项目名称:QueryApi,代码行数:30,代码来源:WhereCollection.php

示例9: compileJoins

 protected function compileJoins(LaravelBaseBuilder $query, $joins)
 {
     $sql = array();
     $query->setBindings(array(), 'join');
     foreach ($joins as $join) {
         $table = $this->wrapTable($join->table);
         // First we need to build all of the "on" clauses for the join. There may be many
         // of these clauses so we will need to iterate through each one and build them
         // separately, then we'll join them up into a single string when we're done.
         $clauses = array();
         foreach ($join->clauses as $where) {
             if (isset($where['type'])) {
                 $method = "where{$where['type']}";
                 $clauses[] = $where['boolean'] . ' ' . $this->{$method}($query, $where);
             } else {
                 $clauses[] = $this->compileJoinConstraint($where);
             }
         }
         foreach ($join->bindings as $binding) {
             $query->addBinding($binding, 'join');
         }
         // Once we have constructed the clauses, we'll need to take the boolean connector
         // off of the first clause as it obviously will not be required on that clause
         // because it leads the rest of the clauses, thus not requiring any boolean.
         $clauses[0] = $this->removeLeadingBoolean($clauses[0]);
         $clauses = implode(' ', $clauses);
         $type = $join->type;
         // Once we have everything ready to go, we will just concatenate all the parts to
         // build the final join statement SQL for the query and we can then return the
         // final clause back to the callers as a single, stringified join statement.
         $sql[] = "{$type} join {$table} on ({$clauses})";
     }
     return implode(' ', $sql);
 }
开发者ID:fembri,项目名称:eloficient,代码行数:34,代码来源:MysqlGrammar.php

示例10: __construct

 /**
  * Create a new join clause instance.
  *
  * @param  \Illuminate\Database\Query\Builder $parentQuery
  * @param  string  $type
  * @param  string  $table
  * @return void
  */
 public function __construct(Builder $parentQuery, $type, $table)
 {
     $this->type = $type;
     $this->table = $table;
     $this->parentQuery = $parentQuery;
     parent::__construct($parentQuery->getConnection(), $parentQuery->getGrammar(), $parentQuery->getProcessor());
 }
开发者ID:delatbabel,项目名称:framework,代码行数:15,代码来源:JoinClause.php

示例11: where

 /**
  * {@inheritdoc}
  */
 public function where(Builder $query, $value, $operator = '=')
 {
     if ($value === self::NULL_VALUE) {
         $value = null;
     }
     return $query->where($this->initQuery($query), $operator, $value);
 }
开发者ID:lazychaser,项目名称:shopping,代码行数:10,代码来源:AbstractProperty.php

示例12: applyAnd

 /**
  * Call apply() within an "and" block
  * @param \Illuminate\Database\Query\Builder $query
  * @return \Illuminate\Database\Query\Builder $query
  */
 public function applyAnd(\Illuminate\Database\Query\Builder $query)
 {
     $query->where(function ($query) {
         $this->apply($query);
     });
     return $query;
 }
开发者ID:simmatrix,项目名称:laravel-query-builder-templates,代码行数:12,代码来源:AbstractScope.php

示例13: constrainByModel

 /**
  * Constrain a query to an ability for a specific model.
  *
  * @param  \Illuminate\Database\Eloquent\Builder|\Illuminate\Database\Query\Builder  $query
  * @param  \Illuminate\Database\Eloquent\Model  $model
  * @param  bool  $strict
  * @return void
  */
 protected function constrainByModel($query, Model $model, $strict = false)
 {
     $query->where(function ($query) use($model, $strict) {
         $query->where($this->table . '.entity_type', $model->getMorphClass());
         $query->where($this->abilitySubqueryConstraint($model, $strict));
     });
 }
开发者ID:JosephSilber,项目名称:bouncer,代码行数:15,代码来源:AbilitiesForModel.php

示例14: prepareStatement

 /**
  * Get prepared statement.
  *
  * @param Builder $query
  * @param string $sql
  * @return \PDOStatement|\Yajra\Pdo\Oci8
  */
 private function prepareStatement(Builder $query, $sql)
 {
     /** @var \Yajra\Oci8\Oci8Connection $connection */
     $connection = $query->getConnection();
     $pdo = $connection->getPdo();
     return $pdo->prepare($sql);
 }
开发者ID:yajra,项目名称:laravel-oci8,代码行数:14,代码来源:OracleProcessor.php

示例15: order

 /**
  * {@inheritdoc}
  */
 public function order(Builder $builder, $direction)
 {
     if ($this->columnClause !== null) {
         $builder->orderBy($this->columnClause, $direction);
     }
     return $this;
 }
开发者ID:guratr,项目名称:cruddy,代码行数:10,代码来源:Computed.php


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