• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP Database\Connection类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

 private function _explainAndShowIndex(Connection $connection, $sql, $bindings)
 {
     $explainResults = $connection->select('explain ' . $sql, $bindings);
     foreach ($explainResults as $explainResult) {
         $results = get_object_vars($explainResult);
         $results['sql'] = $sql;
         $this->explainResults[] = $results;
         if (empty($results['table'])) {
             continue;
         }
         $showIndexResults = $connection->select('show index from ' . $results['table']);
         foreach ($showIndexResults as $showIndexResult) {
             $this->showIndexResults[] = get_object_vars($showIndexResult);
         }
     }
 }
开发者ID:htatemi,项目名称:laravel-sql-alert,代码行数:16,代码来源:QueryAnalyzer.php


示例16: getConnection

 /**
  * Returns the database connection.
  *
  * @return \Illuminate\Database\Connection
  * @throws \InvalidArgumentException
  */
 public function getConnection()
 {
     if ($this->connection === null) {
         $this->connection = new Connection($this->pdo, '', $this->tablePrefix);
         // We will now provide the query grammar to the connection.
         switch ($this->driverName) {
             case 'mysql':
                 $queryGrammar = 'Illuminate\\Database\\Query\\Grammars\\MySqlGrammar';
                 break;
             case 'pgsql':
                 $queryGrammar = 'Illuminate\\Database\\Query\\Grammars\\PostgresGrammar';
                 break;
             case 'sqlsrv':
                 $queryGrammar = 'Illuminate\\Database\\Query\\Grammars\\SqlServerGrammar';
                 break;
             case 'sqlite':
                 $queryGrammar = 'Illuminate\\Database\\Query\\Grammars\\SQLiteGrammar';
                 break;
             default:
                 throw new \InvalidArgumentException("Cannot determine grammar to use based on {$this->driverName}.");
                 break;
         }
         $this->connection->setQueryGrammar(new $queryGrammar());
     }
     return $this->connection;
 }
开发者ID:Laxman-SM,项目名称:iron_worker_examples,代码行数:32,代码来源:ConnectionResolver.php


示例17: getLegacyConnection

 /**
  * @param \Illuminate\Database\Connection $eloquentConnection
  *
  * @return \DreamFactory\Core\Database\Connection
  * @throws \DreamFactory\Core\Exceptions\InternalServerErrorException
  */
 public static function getLegacyConnection($eloquentConnection)
 {
     if (empty(static::$connection)) {
         $driver = $eloquentConnection->getDriverName();
         if (empty($driver)) {
             throw new InternalServerErrorException('No database driver supplied');
         }
         $connections = config('database.connections');
         if (empty($connections)) {
             throw new InternalServerErrorException('No connections found in database.connections config');
         }
         $configKeys = [];
         foreach ($connections as $name => $connectionConfig) {
             if ($driver === $name || $driver === $connectionConfig['driver'] || $driver === 'dblib' && $name === 'sqlsrv') {
                 $configKeys = array_keys($connectionConfig);
             }
         }
         if (empty($configKeys)) {
             throw new InternalServerErrorException('Unsupported driver - ' . $driver);
         }
         $config = [];
         foreach ($configKeys as $key) {
             $config[$key] = $eloquentConnection->getConfig($key);
         }
         switch ($driver) {
             case 'sqlite':
                 $dsn = $driver . ":" . $config['database'];
                 break;
             case 'mysql':
                 $dsn = static::getMySqlDsn($config);
                 break;
             case 'pgsql':
                 $dsn = static::getPgSqlDsn($config);
                 break;
             case 'sqlsrv':
             case 'dblib':
                 $dsn = static::getSqlSrvDsn($config);
                 break;
             default:
                 throw new InternalServerErrorException('Unsupported driver - ' . $driver);
                 break;
         }
         $config['dsn'] = $dsn;
         static::$connection = ConnectionFactory::createConnection($driver, $config);
     }
     return static::$connection;
 }
开发者ID:df-arif,项目名称:df-core,代码行数:53,代码来源:ConnectionAdapter.php


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


示例19: append

 /**
  * @param EventStreamInterface $eventStream
  * @return void
  * @throws SerializationException
  */
 public function append(EventStreamInterface $eventStream)
 {
     $events = collect(iterator_to_array($eventStream))->map(function ($event) {
         /** @var EventInterface $event */
         return ['aggregate_root_id' => (string) $event->getAggregateRootId(), 'type' => get_class($event), 'payload' => $this->serializer->serialize($event)];
     });
     $this->db->table('events')->insert($events->toArray());
 }
开发者ID:desmart,项目名称:laravel-event-sourcing,代码行数:13,代码来源:DbEventStore.php


示例20: checkIfHAshIsUnique

 /**
  * @param $table
  * @param $field
  * @param $hash
  * @param $min_length
  * @param $max_length
  * @return string
  */
 private function checkIfHAshIsUnique($table, $field, $hash, $min_length, $max_length)
 {
     if (!$this->db->table($table)->where($field, '=', $hash)->get()) {
         return $hash;
     } else {
         return $this->makeHAsh($table, $field, true, $min_length, $max_length);
     }
 }
开发者ID:raccoonsoftware,项目名称:Blogify,代码行数:16,代码来源:Blogify.php



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP Database\ConnectionInterface类代码示例发布时间:2022-05-23
下一篇:
PHP Cookie\CookieJar类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap