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


PHP Builder::getBindings方法代码示例

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


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

示例1: getArrayFromQuery

 /**
  * Is used for quick selecting of big number of records from database without creating ORM objects
  * @param \Illuminate\Database\Query\Builder $query - Query Builder object
  * @return array $results - results of query
  */
 private static function getArrayFromQuery($query)
 {
     $sql = $query->toSql();
     foreach ($query->getBindings() as $binding) {
         $value = is_numeric($binding) ? $binding : "'" . $binding . "'";
         $sql = preg_replace('/\\?/', $value, $sql, 1);
     }
     $results = \DB::select($sql);
     return $results;
 }
开发者ID:aerynl,项目名称:refinement,代码行数:15,代码来源:Refinement.php

示例2: vsprintf

 /**
  * Render query SQL string.
  *
  * @author Morten Rugaard <moru@nodes.dk>
  *
  * @param  \Illuminate\Database\Query\Builder $query
  * @return string
  */
 function render_sql(\Illuminate\Database\Query\Builder $query)
 {
     return vsprintf($query->toSql(), $query->getBindings());
 }
开发者ID:nodes-php,项目名称:database,代码行数:12,代码来源:Query.php

示例3: toSql

 public static function toSql(Builder $query)
 {
     $sql = $query->toSql();
     $connection = $query->getConnection();
     $pdo = $connection->getPdo();
     $bindings = $query->getBindings();
     $bindings = $connection->prepareBindings($bindings);
     if (!empty($bindings)) {
         foreach ($bindings as $binding) {
             $sql = preg_replace('/\\?/', $pdo->quote($binding), $sql, 1);
         }
     }
     return $sql;
 }
开发者ID:exolnet,项目名称:laravel-module,代码行数:14,代码来源:QueryHelper.php

示例4: getBindings

 /**
  * Get the current query value bindings in a flattened array.
  *
  * @return array 
  * @static 
  */
 public static function getBindings()
 {
     return \Illuminate\Database\Query\Builder::getBindings();
 }
开发者ID:satriashp,项目名称:tour,代码行数:10,代码来源:_ide_helper.php

示例5: whereInExistingQuery

 /**
  * Add a external sub-select to the query.
  *
  * @param  string   $column
  * @param  \Illuminate\Database\Query\Builder|static  $query
  * @param  string   $boolean
  * @param  bool     $not
  * @return $this
  */
 protected function whereInExistingQuery($column, $query, $boolean, $not)
 {
     $type = $not ? 'NotInSub' : 'InSub';
     $this->wheres[] = compact('type', 'column', 'query', 'boolean');
     $this->addBinding($query->getBindings(), 'where');
     return $this;
 }
开发者ID:denise92,项目名称:cms,代码行数:16,代码来源:Builder.php

示例6: addWhereExistsQuery

 /**
  * Add an exists clause to the query.
  *
  * @param  \Illuminate\Database\Query\Builder $query
  * @param  string  $boolean
  * @param  bool  $not
  * @return $this
  */
 public function addWhereExistsQuery(Builder $query, $boolean = 'and', $not = false)
 {
     $type = $not ? 'NotExists' : 'Exists';
     $this->wheres[] = compact('type', 'operator', 'query', 'boolean');
     $this->addBinding($query->getBindings(), 'where');
     return $this;
 }
开发者ID:denise92,项目名称:cms,代码行数:15,代码来源:Builder.php

示例7: addNestedWhereQuery

 /**
  * Add another query builder as a nested where to the query builder.
  *
  * @param  \Illuminate\Database\Query\Builder|static $query
  * @param  string  $boolean
  * @return $this
  */
 public function addNestedWhereQuery($query, $boolean = 'and')
 {
     if (count($query->wheres)) {
         $type = 'Nested';
         $this->wheres[] = compact('type', 'query', 'boolean');
         $this->addBinding($query->getBindings(), 'where');
     }
     return $this;
 }
开发者ID:stevedaddy,项目名称:react,代码行数:16,代码来源:Builder.php

示例8: whereCountQuery

 /**
  * Add a sub query count clause to the query.
  *
  * @param  \Illuminate\Database\Query\Builder $query
  * @param  string  $operator
  * @param  int  $count
  * @param  string  $boolean
  * @return $this
  */
 protected function whereCountQuery(QueryBuilder $query, $operator = '>=', $count = 1, $boolean = 'and')
 {
     if (is_numeric($count)) {
         $count = new Expression($count);
     }
     $this->query->addBinding($query->getBindings(), 'where');
     return $this->where(new Expression('(' . $query->toSql() . ')'), $operator, $count, $boolean);
 }
开发者ID:levanigongadze,项目名称:Labweb,代码行数:17,代码来源:Builder.php

示例9: performCountQuery

 /**
  * Performs the count query and returns info about the pages
  *
  * @param \Illuminate\Database\Query\Builder	$countQuery
  * @param string								$querySql
  * @param int									$page
  *
  * @return array
  */
 public function performCountQuery(QueryBuilder $countQuery, $querySql, $page)
 {
     //grab the model instance
     $model = $this->config->getDataModel();
     //then wrap the inner table and perform the count
     $sql = "SELECT COUNT({$model->getKeyName()}) AS aggregate FROM ({$querySql}) AS agg";
     //then perform the count query
     $results = $countQuery->getConnection()->select($sql, $countQuery->getBindings());
     $numRows = $results[0]->aggregate;
     $page = (int) $page;
     $last = (int) ceil($numRows / $this->rowsPerPage);
     return array('page' => $page > $last ? $last : $page, 'last' => $last, 'total' => $numRows);
 }
开发者ID:EmersonStone,项目名称:Laravel-Administrator,代码行数:22,代码来源:DataTable.php

示例10: getQueryKey

 protected function getQueryKey(Builder $builder, $other = null)
 {
     $name = $builder->getConnection()->getName();
     return md5($name . $builder->toSql() . serialize($builder->getBindings()) . $other);
 }
开发者ID:pushoperations,项目名称:magician,代码行数:5,代码来源:Repository.php

示例11: whereSubQuery

 /**
  * Add a full sub-select to the query.
  *
  * @param string $column
  * @param \Illuminate\Database\Query\Builder $query
  * @param string $boolean
  * @return $this
  */
 public function whereSubQuery($column, $query, $boolean = 'and')
 {
     list($type, $operator) = ['Sub', 'in'];
     $this->wheres[] = compact('type', 'column', 'operator', 'query', 'boolean');
     $this->addBinding($query->getBindings(), 'where');
     return $this;
 }
开发者ID:laraplus,项目名称:translatable,代码行数:15,代码来源:QueryBuilder.php

示例12: getConditionStringFromQueryBuilder

 /**
  * Extracts a raw WHERE clause string from a QueryBuilder instance.
  * Note that this is practically identical to the original Listify.
  *
  * @param QueryBuilder $query A Query Builder instance
  * @return string
  */
 protected function getConditionStringFromQueryBuilder(QueryBuilder $query)
 {
     $initialQueryChunks = explode('where ', $query->toSql());
     if (count($initialQueryChunks) == 1) {
         throw new InvalidArgumentException('The query builder instance must have a where clause to build a condition string from');
     }
     $queryChunks = explode('?', $initialQueryChunks[1]);
     $chunkCount = count($queryChunks);
     $bindings = $query->getBindings();
     $whereString = '';
     for ($i = 0; $i < $chunkCount; $i++) {
         $whereString .= $queryChunks[$i];
         if (isset($bindings[$i])) {
             if (gettype($bindings[$i]) === 'string') {
                 $whereString .= '"' . $bindings[$i] . '"';
             }
         }
     }
     return $whereString;
 }
开发者ID:czim,项目名称:laravel-listify,代码行数:27,代码来源:Listify.php

示例13: toSql

 /**
  * Return sql statement
  * 
  * @param  Builder $queryBuilder 
  * @return string                
  */
 public static function toSql(Builder $queryBuilder)
 {
     $params = $queryBuilder->getBindings();
     $pdoStatement = $queryBuilder->toSql();
     foreach ($params as $param) {
         $param = is_int($param) ? $param : "'{$param}'";
         $pdoStatement = str_replace_first('?', $param, $pdoStatement);
     }
     return str_replace('`', '', $pdoStatement);
 }
开发者ID:jocoonopa,项目名称:lubri,代码行数:16,代码来源:Processor.php

示例14: generateQueryHashFromQueryBuilder

 /**
  * @param Builder $qb
  * @param array $attributes
  */
 private function generateQueryHashFromQueryBuilder(Builder $qb, array $attributes)
 {
     $this->actualQueryHash = sha1(implode('_', [$this->cacheHashKeyPrefix, $qb->toSql(), serialize($qb->getBindings()), serialize($attributes)]));
 }
开发者ID:Algatux,项目名称:laravel-repository,代码行数:8,代码来源:CacheManager.php

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