當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。