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


PHP Builder::getConnection方法代码示例

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


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

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

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

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

示例4: count

 /**
  * Get rows count
  *
  * @return int
  */
 public function count()
 {
     $connection = $this->query->getConnection();
     $myQuery = clone $this->query;
     // if its a normal query ( no union, having and distinct word )
     // replace the select with static text to improve performance
     if (!Str::contains(Str::lower($myQuery->toSql()), ['union', 'having', 'distinct', 'order by', 'group by'])) {
         $row_count = $connection->getQueryGrammar()->wrap('row_count');
         $myQuery->select($connection->raw("'1' as {$row_count}"));
     }
     return $connection->table($connection->raw('(' . $myQuery->toSql() . ') count_row_table'))->setBindings($myQuery->getBindings())->count();
 }
开发者ID:mikelmi,项目名称:mks-smart-table,代码行数:17,代码来源:QueryBuilderEngine.php

示例5: fields

 /**
  * @param array $fields
  * @return array
  */
 public function fields($fields = [])
 {
     if (empty($fields)) {
         $conn = $this->operator->getConnection();
         if ($conn->getName() == 'mysql') {
             $results = $conn->select((new \Illuminate\Database\Schema\Grammars\MySqlGrammar())->compileColumnExists(), [$conn->getDatabaseName(), $conn->getTablePrefix() . $this->table]);
             $this->_fields = array_map(function ($v) {
                 return is_array($v) ? $v['column_name'] : $v->column_name;
             }, $results);
         }
     }
     return $this->_fields;
 }
开发者ID:kyleing,项目名称:gtbool,代码行数:17,代码来源:DBOperator.php

示例6: 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)
 {
     $result = $query->getConnection()->selectFromWriteConnection($sql, $values)[0];
     $sequence = $sequence ?: 'id';
     $id = is_object($result) ? $result->{$sequence} : $result[$sequence];
     return is_numeric($id) ? (int) $id : $id;
 }
开发者ID:davidhemphill,项目名称:framework,代码行数:16,代码来源:PostgresProcessor.php

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

示例8: parseFullTextSearch

 /**
  * Parse the fulltext search parameter q
  *
  * @param  string $qParam
  * @param  array  $fullTextSearchColumns
  * @return void
  */
 protected function parseFullTextSearch($qParam, $fullTextSearchColumns)
 {
     if ($qParam == '') {
         //Add where that will never be true
         $this->query->whereRaw('0 = 1');
         return;
     }
     $fulltextType = Config::get('apihandler.fulltext');
     if ($fulltextType == 'native') {
         //Use pdo's quote method to be protected against sql-injections.
         //The usual placeholders unfortunately don't seem to work using AGAINST().
         $qParam = $this->query->getConnection()->getPdo()->quote($qParam);
         //Use native fulltext search
         $this->query->whereRaw('MATCH(' . implode(',', $fullTextSearchColumns) . ') AGAINST("' . $qParam . '" IN BOOLEAN MODE)');
         //Add the * to the selects because of the score column
         if (count($this->query->columns) == 0) {
             $this->query->addSelect('*');
         }
         //Add the score column
         $scoreColumn = Config::get('apihandler.fulltext_score_column');
         $this->query->addSelect($this->query->raw('MATCH(' . implode(',', $fullTextSearchColumns) . ') AGAINST("' . $qParam . '" IN BOOLEAN MODE) as `' . $scoreColumn . '`'));
     } else {
         $keywords = explode(' ', $qParam);
         //Use default php implementation
         $this->query->where(function ($query) use($fullTextSearchColumns, $keywords) {
             foreach ($fullTextSearchColumns as $column) {
                 foreach ($keywords as $keyword) {
                     $query->orWhere($column, 'LIKE', '%' . $keyword . '%');
                 }
             }
         });
     }
 }
开发者ID:marcelgwerder,项目名称:laravel-api-handler,代码行数:40,代码来源:Parser.php

示例9: 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)
 {
     $query->getConnection()->insert($sql, $values);
     try {
         $id = $query->getConnection()->getPdo()->lastInsertId();
     } catch (\PDOException $e) {
         if ($e->getCode() == 'IM001') {
             $sth = $query->getConnection()->getPdo()->query("SELECT CAST(COALESCE(SCOPE_IDENTITY(), @@IDENTITY) AS int)");
             $sth->execute();
             $result = $sth->fetch();
             $id = $result[0];
         } else {
             throw $e;
         }
     }
     return is_numeric($id) ? (int) $id : $id;
 }
开发者ID:rtroncoso,项目名称:odbc-driver,代码行数:26,代码来源:ODBCDriverProcessor.php

示例10: simplePaginate

 /**
  * Get a paginator only supporting simple next and previous links.
  *
  * This is more efficient on larger data-sets, etc.
  *
  * @param  int    $perPage
  * @param  array  $columns
  * @return \Illuminate\Pagination\Paginator
  */
 public function simplePaginate($perPage = null, $columns = array('*'))
 {
     $paginator = $this->query->getConnection()->getPaginator();
     $page = $paginator->getCurrentPage();
     $perPage = $perPage ?: $this->model->getPerPage();
     $this->query->skip(($page - 1) * $perPage)->take($perPage + 1);
     return $paginator->make($this->get($columns)->all(), $perPage);
 }
开发者ID:peintune,项目名称:Ternado,代码行数:17,代码来源:Builder.php

示例11: firstOrCreate

 /**
  * Get the first record matching the attributes or create it.
  *
  * @param  array  $attributes
  * @param  array  $values
  * @return \Illuminate\Database\Eloquent\Model
  */
 public function firstOrCreate(array $attributes, array $values = [])
 {
     if (!is_null($instance = $this->where($attributes)->first())) {
         return $instance;
     }
     $instance = $this->model->newInstance($attributes + $values)->setConnection($this->query->getConnection()->getName());
     $instance->save();
     return $instance;
 }
开发者ID:illuminate,项目名称:database,代码行数:16,代码来源:Builder.php

示例12: paginate

 /**
  * Get a paginator for the "select" statement.
  *
  * @param  int    $perPage
  * @param  array  $columns
  * @return \Illuminate\Pagination\Paginator
  */
 public function paginate($perPage = null, $columns = array('*'))
 {
     $perPage = $perPage ?: $this->model->getPerPage();
     $paginator = $this->query->getConnection()->getPaginator();
     if (isset($this->query->groups)) {
         return $this->groupedPaginate($paginator, $perPage, $columns);
     } else {
         return $this->ungroupedPaginate($paginator, $perPage, $columns);
     }
 }
开发者ID:aysenli,项目名称:laravel-admin-1,代码行数:17,代码来源:Builder.php

示例13: __construct

 /**
  * EloquentManager constructor.
  *
  * @param Builder|\Eloquent $model
  * @param Request $request
  */
 public function __construct($model, Request $request)
 {
     $this->response = new DataTable();
     $this->query = $model instanceof Builder ? $model : $model->getQuery();
     $this->request = $request;
     //        $this->columns    = $this->query->columns;
     $this->connection = $model->getConnection();
     $this->prefix = $this->connection->getTablePrefix();
     $this->database = $this->connection->getDriverName();
 }
开发者ID:maurob45,项目名称:eloquentdatatables,代码行数:16,代码来源:EloquentManager.php

示例14: 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)
 {
     $connection = $query->getConnection();
     $connection->insert($sql, $values);
     if ($connection->getConfig('odbc') === true) {
         $id = $this->processInsertGetIdForOdbc($connection);
     } else {
         $id = $connection->getPdo()->lastInsertId();
     }
     return is_numeric($id) ? (int) $id : $id;
 }
开发者ID:timpressive,项目名称:art-auction,代码行数:20,代码来源:SqlServerProcessor.php

示例15: init

 /**
  * Initialize attributes.
  *
  * @param  \Yajra\Datatables\Request $request
  * @param  \Illuminate\Database\Query\Builder $builder
  * @param  string $type
  */
 protected function init($request, $builder, $type = 'builder')
 {
     $this->request = $request;
     $this->query_type = $type;
     $this->columns = $builder->columns;
     $this->connection = $builder->getConnection();
     $this->prefix = $this->connection->getTablePrefix();
     $this->database = $this->connection->getDriverName();
     if ($this->isDebugging()) {
         $this->connection->enableQueryLog();
     }
 }
开发者ID:ariefbudianto,项目名称:biogold,代码行数:19,代码来源:QueryBuilderEngine.php


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