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


PHP Database\Connection类代码示例

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


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

示例1: compileRenameColumn

 /**
  * Compile a rename column command.
  *
  * @param  \Illuminate\Database\Schema\Blueprint  $blueprint
  * @param  \Illuminate\Support\Fluent  $command
  * @param  \Illuminate\Database\Connection  $connection
  * @return array
  */
 public function compileRenameColumn(Blueprint $blueprint, Fluent $command, Connection $connection)
 {
     $schema = $connection->getDoctrineSchemaManager();
     $column = $connection->getDoctrineColumn($blueprint->getTable(), $command->from);
     $tableDiff = $this->getRenamedDiff($blueprint, $command, $column, $schema);
     return (array) $schema->getDatabasePlatform()->getAlterTableSQL($tableDiff);
 }
开发者ID:Thomvh,项目名称:turbine,代码行数:15,代码来源:Grammar.php

示例2: __construct

 public function __construct(Connection $connection, RepositoryContract $config)
 {
     $dbconfig = $config->get('database.connections.' . $connection->getName());
     $this->dsn = static::parseDSN($dbconfig);
     $this->username = $dbconfig['username'];
     $this->password = $dbconfig['password'];
 }
开发者ID:recca0120,项目名称:laravel-support,代码行数:7,代码来源:Backup.php

示例3: __construct

 public function __construct(\Illuminate\Database\Connection $connection)
 {
     if (!$connection->getSchemaGrammar()) {
         $connection->useDefaultGrammar();
     }
     parent::__construct($connection);
 }
开发者ID:offworks,项目名称:laraquent,代码行数:7,代码来源:Schema.php

示例4: addQuery

 /**
  *
  * @param string $query
  * @param array $bindings
  * @param float $time
  * @param \Illuminate\Database\Connection $connection
  */
 public function addQuery($query, $bindings, $time, $connection)
 {
     $time = $time / 1000;
     $endTime = microtime(true);
     $startTime = $endTime - $time;
     $pdo = $connection->getPdo();
     $bindings = $connection->prepareBindings($bindings);
     $bindings = $this->checkBindings($bindings);
     if (!empty($bindings) && $this->renderSqlWithParams) {
         foreach ($bindings as $binding) {
             $query = preg_replace('/\\?/', $pdo->quote($binding), $query, 1);
         }
     }
     $source = null;
     if ($this->findSource) {
         try {
             $source = $this->findSource();
         } catch (\Exception $e) {
         }
     }
     $this->queries[] = array('query' => $query, 'bindings' => $bindings, 'time' => $time, 'source' => $source);
     if ($this->timeCollector !== null) {
         $this->timeCollector->addMeasure($query, $startTime, $endTime);
     }
 }
开发者ID:jairoserrano,项目名称:SimpleBlogClase,代码行数:32,代码来源:QueryCollector.php

示例5: __construct

 /**
  * @param Connection $connection
  */
 public function __construct(Connection $connection)
 {
     $this->connection = $connection;
     $this->grammar = $connection->getSchemaGrammar();
     $this->helper = new OracleAutoIncrementHelper($connection);
     $this->comment = new Comment($connection);
 }
开发者ID:bryan-mwas,项目名称:Clearance101,代码行数:10,代码来源:OracleBuilder.php

示例6: addQuery

 /**
  *
  * @param string $query
  * @param array $bindings
  * @param float $time
  * @param \Illuminate\Database\Connection $connection
  */
 public function addQuery($query, $bindings, $time, $connection)
 {
     $explainResults = array();
     $time = $time / 1000;
     $endTime = microtime(true);
     $startTime = $endTime - $time;
     $hints = $this->performQueryAnalysis($query);
     $pdo = $connection->getPdo();
     $bindings = $connection->prepareBindings($bindings);
     // Run EXPLAIN on this query (if needed)
     if ($this->explainQuery && preg_match('/^(' . implode($this->explainTypes) . ') /i', $query)) {
         $statement = $pdo->prepare('EXPLAIN ' . $query);
         $statement->execute($bindings);
         $explainResults = $statement->fetchAll(\PDO::FETCH_CLASS);
     }
     $bindings = $this->checkBindings($bindings);
     if (!empty($bindings) && $this->renderSqlWithParams) {
         foreach ($bindings as $binding) {
             $query = preg_replace('/\\?/', $pdo->quote($binding), $query, 1);
         }
     }
     $source = null;
     if ($this->findSource) {
         try {
             $source = $this->findSource();
         } catch (\Exception $e) {
         }
     }
     $this->queries[] = array('query' => $query, 'bindings' => $this->escapeBindings($bindings), 'time' => $time, 'source' => $source, 'explain' => $explainResults, 'hints' => $hints);
     if ($this->timeCollector !== null) {
         $this->timeCollector->addMeasure($query, $startTime, $endTime);
     }
 }
开发者ID:aleguisf,项目名称:fvdev1,代码行数:40,代码来源:QueryCollector.php

示例7: getSchemaBuilder

 /**
  * Retrieve the schema builder for the database connection. And set a custom blueprint resolver to return an
  * instance of the Culpa Blueprint class.
  *
  * @param Connection $connection
  * @return \Illuminate\Database\Schema\Builder
  */
 protected static function getSchemaBuilder(Connection $connection)
 {
     $schemaBuilder = $connection->getSchemaBuilder();
     $schemaBuilder->blueprintResolver(function ($table, $callback) {
         return new Blueprint($table, $callback);
     });
     return $schemaBuilder;
 }
开发者ID:nstapelbroek,项目名称:culpa-laravel-5,代码行数:15,代码来源:Schema.php

示例8: processInsertGetIdForOdbc

 /**
  * Process an "insert get ID" query for ODBC.
  *
  * @param  \Illuminate\Database\Connection  $connection
  * @return int
  */
 protected function processInsertGetIdForOdbc($connection)
 {
     $result = $connection->select('SELECT CAST(COALESCE(SCOPE_IDENTITY(), @@IDENTITY) AS int) AS insertid');
     if (!$result) {
         throw new Exception('Unable to retrieve lastInsertID for ODBC.');
     }
     return $result[0]->insertid;
 }
开发者ID:imydou,项目名称:dkuu,代码行数:14,代码来源:SqlServerProcessor.php

示例9: getNickId

 /**
  * @param \Illuminate\Database\Connection $db
  * @param int                             $channelId
  * @param string                          $nick
  * @return int
  */
 protected function getNickId(Connection $db, $channelId, $nick)
 {
     $targetNick = $db->table('nicks')->select('id')->where('channel_id', '=', $channelId)->where('nick', '=', $nick)->first();
     if ($targetNick) {
         return $targetNick['id'];
     } else {
         return $db->table('nicks')->insertGetId(['channel_id' => $channelId, 'nick' => $nick]);
     }
 }
开发者ID:tomzx,项目名称:irc-stats,代码行数:15,代码来源:Parser.php

示例10: processInsertGetIdForOdbc

 /**
  * Process an "insert get ID" query for ODBC.
  *
  * @param  \Illuminate\Database\Connection  $connection
  * @return int
  */
 protected function processInsertGetIdForOdbc($connection)
 {
     $result = $connection->selectFromWriteConnection('SELECT CAST(COALESCE(SCOPE_IDENTITY(), @@IDENTITY) AS int) AS insertid');
     if (!$result) {
         throw new Exception('Unable to retrieve lastInsertID for ODBC.');
     }
     $row = $result[0];
     return is_object($row) ? $row->insertid : $row['insertid'];
 }
开发者ID:timpressive,项目名称:art-auction,代码行数:15,代码来源:SqlServerProcessor.php

示例11: __construct

 /**
  * Create a new schema blueprint.
  *
  * @param string  $table
  * @param Closure $callback
  */
 public function __construct(Connection $connection, $collection)
 {
     $this->connection = $connection;
     try {
         $this->collection = $connection->getCollection($collection);
     } catch (\Illuminate\Database\Eloquent\ModelNotFoundException $e) {
         $this->collection = ['type' => $collection];
     }
 }
开发者ID:AndresRojasIsaza,项目名称:laravel-couchdb,代码行数:15,代码来源:Blueprint.php

示例12: compileCreateEncoding

 /**
  * Append the character set specifications to a command.
  *
  * @param  string  $sql
  * @param  \Illuminate\Database\Connection  $connection
  * @return string
  */
 protected function compileCreateEncoding($sql, Connection $connection)
 {
     if (!is_null($charset = $connection->getConfig('charset'))) {
         $sql .= ' default character set ' . $charset;
     }
     if (!is_null($collation = $connection->getConfig('collation'))) {
         $sql .= ' collate ' . $collation;
     }
     return $sql;
 }
开发者ID:betes-curieuses-design,项目名称:ElieJosiePhotographie,代码行数:17,代码来源:MySqlGrammar.php

示例13: prepare

 /**
  * Prepare the database connection instance.
  *
  * @param  Illuminate\Database\Connection  $connection
  * @return Illuminate\Database\Connection
  */
 protected function prepare(Connection $connection)
 {
     $connection->setFetchMode($this->app['config']['database.fetch']);
     $connection->setEventDispatcher($this->app['events']);
     // We will setup a Closure to resolve the paginator instance on the connection
     // since the Paginator isn't sued on every request and needs quite a few of
     // our dependencies. It'll be more efficient to lazily resolve instances.
     $app = $this->app;
     $connection->setPaginator(function () use($app) {
         return $app['paginator'];
     });
     return $connection;
 }
开发者ID:hochanh,项目名称:Bootsoft-Bowling,代码行数:19,代码来源:DatabaseManager.php

示例14: compileCreateEncoding

 /**
  * Append the character set specifications to a command.
  *
  * @param  string  $sql
  * @param  \Illuminate\Database\Connection  $connection
  * @param  \Illuminate\Database\Schema\Blueprint  $blueprint
  * @return string
  */
 protected function compileCreateEncoding($sql, Connection $connection, Blueprint $blueprint)
 {
     if (isset($blueprint->charset)) {
         $sql .= ' default character set ' . $blueprint->charset;
     } elseif (!is_null($charset = $connection->getConfig('charset'))) {
         $sql .= ' default character set ' . $charset;
     }
     if (isset($blueprint->collation)) {
         $sql .= ' collate ' . $blueprint->collation;
     } elseif (!is_null($collation = $connection->getConfig('collation'))) {
         $sql .= ' collate ' . $collation;
     }
     return $sql;
 }
开发者ID:janhartigan,项目名称:framework,代码行数:22,代码来源:MySqlGrammar.php

示例15: drop

 /**
  * function to safely drop trigger db object
  *
  * @param  string $name
  * @return boolean
  */
 public function drop($name)
 {
     if (!$name) {
         return false;
     }
     return $this->connection->statement("\n            declare\n                e exception;\n                pragma exception_init(e,-4080);\n            begin\n                execute immediate 'drop trigger {$name}';\n            exception\n            when e then\n                null;\n            end;");
 }
开发者ID:bryan-mwas,项目名称:Clearance101,代码行数:13,代码来源:Trigger.php


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