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


PHP Builder::toSql方法代码示例

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


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

示例4: getValue

 /**
  * Evaluate query as string.
  *
  * @return string
  */
 public function getValue()
 {
     $sql = '(' . $this->query->toSql() . ')';
     if ($this->alias) {
         $alias = $this->query->getGrammar()->wrapTable($this->alias);
         $sql .= ' as ' . $alias;
     }
     return $sql;
 }
开发者ID:rafwlaz,项目名称:eloquence,代码行数:14,代码来源:Subquery.php

示例5: 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

示例6: toSql

 /**
  * Get the SQL representation of the query.
  *
  * @return string 
  * @static 
  */
 public static function toSql()
 {
     return \Illuminate\Database\Query\Builder::toSql();
 }
开发者ID:satriashp,项目名称:tour,代码行数:10,代码来源:_ide_helper.php

示例7: 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

示例8: 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

示例9: 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

示例10: 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

示例11: toSql

 /**
  * Get the SQL representation of the query.
  *
  * @return string
  */
 public function toSql()
 {
     return $this->query->toSql();
 }
开发者ID:mint-soft-com,项目名称:xpressengine,代码行数:9,代码来源:DynamicQuery.php

示例12: 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


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