當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Connection::getPdo方法代碼示例

本文整理匯總了PHP中Illuminate\Database\Connection::getPdo方法的典型用法代碼示例。如果您正苦於以下問題:PHP Connection::getPdo方法的具體用法?PHP Connection::getPdo怎麽用?PHP Connection::getPdo使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Illuminate\Database\Connection的用法示例。


在下文中一共展示了Connection::getPdo方法的11個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

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

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

示例3: ensureTransaction

 /**
  * Enures the given closur is executed within a PDO transaction.
  *
  * @param  Closure  $callback
  * @return void
  */
 public function ensureTransaction(Closure $callback)
 {
     if (!$this->connection->getPdo()->inTransaction()) {
         $this->connection->transaction($callback);
     } else {
         $callback($this->connection);
     }
 }
開發者ID:sohailaammarocs,項目名稱:lfc,代碼行數:14,代碼來源:IlluminateWorker.php

示例4: addQuery

 /**
  *
  * @param string $query
  * @param array $bindings
  * @param float $time
  * @param \Illuminate\Database\Connection $connection
  */
 public function addQuery($query, $bindings, $time, $connection)
 {
     $explainResults = [];
     $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 $key => $binding) {
             // This regex matches placeholders only, not the question marks,
             // nested in quotes, while we iterate through the bindings
             // and substitute placeholders by suitable values.
             $regex = is_numeric($key) ? "/\\?(?=(?:[^'\\\\']*'[^'\\\\']*')*[^'\\\\']*\$)/" : "/:{$key}(?=(?:[^'\\\\']*'[^'\\\\']*')*[^'\\\\']*\$)/";
             $query = preg_replace($regex, $pdo->quote($binding), $query, 1);
         }
     }
     $source = null;
     if ($this->findSource) {
         try {
             $source = $this->findSource();
         } catch (\Exception $e) {
         }
     }
     $this->queries[] = ['query' => $query, 'bindings' => $this->escapeBindings($bindings), 'time' => $time, 'source' => $source, 'explain' => $explainResults, 'connection' => $connection->getDatabaseName(), 'hints' => $this->showHints ? $hints : null];
     if ($this->timeCollector !== null) {
         $this->timeCollector->addMeasure($query, $startTime, $endTime);
     }
 }
開發者ID:barryvdh,項目名稱:laravel-debugbar,代碼行數:44,代碼來源:QueryCollector.php

示例5: setPdoForType

 /**
  * Prepare the read write mode for database connection instance.
  *
  * @param  \Illuminate\Database\Connection  $connection
  * @param  string  $type
  * @return \Illuminate\Database\Connection
  */
 protected function setPdoForType(Connection $connection, $type = null)
 {
     if ($type == 'read') {
         $connection->setPdo($connection->getReadPdo());
     } elseif ($type == 'write') {
         $connection->setReadPdo($connection->getPdo());
     }
     return $connection;
 }
開發者ID:hilmysyarif,項目名稱:sisfito,代碼行數:16,代碼來源:DatabaseManager.php

示例6: __construct

 /**
  * @param null|string $connectionName
  */
 public function __construct($connectionName = null)
 {
     $connection = is_null($connectionName) ? Config::get('database.default') : DB::connection($connectionName);
     $this->connection = DB::connection($connection);
     $this->connection->getPdo()->exec('use INFORMATION_SCHEMA');
 }
開發者ID:simlux,項目名稱:laravel-generator,代碼行數:9,代碼來源:InformationSchema.php

示例7: getLastId

 public function getLastId()
 {
     return $this->connection->getPdo()->lastInsertId();
 }
開發者ID:newcart,項目名稱:system,代碼行數:4,代碼來源:DB.php

示例8: isConnected

 public function isConnected()
 {
     return !empty($this->connection) && $this->connection->getPdo() instanceof \PDO;
 }
開發者ID:minutephp,項目名稱:framework,代碼行數:4,代碼來源:Database.php

示例9: getTraceablePdo

 public function getTraceablePdo()
 {
     return new TraceablePDO($this->db->getPdo());
 }
開發者ID:raisoblast,項目名稱:rakitan,代碼行數:4,代碼來源:PhpDebugBarEloquentCollector.php

示例10: boot

 public function boot(Connection $db)
 {
     $this->publishes([__DIR__ . '/config/log.php' => config_path('log.php')], 'zedisdog/mysqlHandler');
     $mysqlHandler = new MySQLHandler($db->getPdo(), config('log.table', 'log'), [], Logger::DEBUG);
     \Log::getMonolog()->pushHandler($mysqlHandler);
 }
開發者ID:zedisdog,項目名稱:monolog-database-handler-for-laravel5,代碼行數:6,代碼來源:MysqlHandlerServiceProvider.php

示例11: createDatabase

    /**
     * @param Connection $db
     * @param array      $creds
     *
     * @return bool
     */
    protected function createDatabase($db, array $creds)
    {
        try {
            $_dbName = $creds['database'];
            if (false === $db->statement(<<<MYSQL
CREATE DATABASE IF NOT EXISTS `{$_dbName}`
MYSQL
)) {
                throw new DatabaseException(json_encode($db->getPdo()->errorInfo()));
            }
            return true;
        } catch (\Exception $_ex) {
            $this->error('[provisioning:database] create database - failure: ' . $_ex->getMessage());
            return false;
        }
    }
開發者ID:rajeshpillai,項目名稱:dfe-dreamfactory-provisioner,代碼行數:22,代碼來源:DatabaseProvisioner.php


注:本文中的Illuminate\Database\Connection::getPdo方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。