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


PHP Connection::getDriver方法代碼示例

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


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

示例1: getDsn

 public function getDsn()
 {
     $driver = $this->connection->getDriver()->getName();
     $user = $this->connection->getUsername();
     $pass = $this->connection->getPassword();
     $host = $this->connection->getHost();
     $db = $this->connection->getDatabase();
     return "{$driver}://{$user}:{$pass}@{$host}/{$db}";
 }
開發者ID:jfortunato,項目名稱:quickbooks-desktop-bundle,代碼行數:9,代碼來源:Config.php

示例2: __construct

 /**
  * Create a new connection wrapping a Doctrine DBAL connection.
  * 
  * @param DoctrineConnection $conn 
  * @param array<string, mixed> $options
  */
 public function __construct(DoctrineConnection $conn, array $options = [])
 {
     $this->conn = $conn;
     $this->options = $options;
     switch ($conn->getDriver()->getName()) {
         case 'pdo_sqlite':
             $this->driverName = DB::DRIVER_SQLITE;
             $this->initializeSqlite();
             break;
         case 'pdo_mysql':
         case 'drizzle_pdo_mysql':
         case 'mysqli':
             $this->driverName = DB::DRIVER_MYSQL;
             break;
         case 'pdo_pgsql':
             $this->driverName = DB::DRIVER_POSTGRESQL;
             break;
         case 'pdo_oci':
         case 'oci8':
             $this->driverName = DB::DRIVER_ORACLE;
             break;
         case 'pdo_sqlsrv':
         case 'sqlsrv':
             $this->driverName = DB::DRIVER_MSSQL;
             break;
         case 'ibm_db2':
             $this->driverName = DB::DRIVER_DB2;
             break;
     }
 }
開發者ID:koolkode,項目名稱:database,代碼行數:36,代碼來源:Connection.php

示例3: addConnection

 /**
  * @param string                    $name
  * @param \Doctrine\DBAL\Connection $connection
  */
 public static function addConnection($name, \Doctrine\DBAL\Connection $connection)
 {
     if ($connection->getDriver() instanceof \Doctrine\DBAL\Driver\PDOMySql\Driver) {
         static::$connections[$name] = $connection;
     } else {
         throw new ErrorException("Database connection must use a \\Doctrine\\DBAL\\Driver\\PDOMySql\\Driver Driver");
     }
 }
開發者ID:AlexValGal,項目名稱:Practica-FInal-DIW-DWC,代碼行數:12,代碼來源:Config.php

示例4: run

 public function run($sourceFile, Connection $dbConn)
 {
     $driverType = $dbConn->getDriver()->getName();
     $sqlite = preg_match('/sqlite/i', $driverType);
     $objPHPExcel = \PHPExcel_IOFactory::load($sourceFile);
     $dbConn->exec($sqlite ? 'DELETE FROM songs' : 'TRUNCATE TABLE songs');
     // empty table - reset autoincrement if it has one
     $iterator = $objPHPExcel->getSheet()->getRowIterator($this->startRow);
     $i = 1;
     $codeStored = [];
     foreach ($iterator as $row) {
         $raw = [];
         /** @var \PHPExcel_Worksheet_Row $row */
         //            $rowIdx = $row->getRowIndex();
         $cells = $row->getCellIterator();
         foreach ($cells as $cell) {
             /** @var \PHPExcel_Cell $cell */
             $column = $cell->getColumn();
             $content = $cell->getFormattedValue();
             $targetField = isset($this->fileFields[$column]) ? $this->fileFields[$column] : null;
             if ($targetField) {
                 $raw[$targetField] = trim($content);
             }
         }
         //map row
         $storable = $this->rowToStorable($raw);
         //            print_r($storable);
         if (strlen(join($storable, ''))) {
             if ($sqlite && !isset($storable['id'])) {
                 $storable['id'] = $i;
             }
             if (!isset($storable['codeNumber'])) {
                 $storable['codeNumber'] = (string) $this->makeCodeNumberFromArray($storable);
             }
             if (isset($codeStored[$storable['codeNumber']])) {
                 print "\nDuplicate: " . $storable[self::INPUT_FIELD_ARTIST] . ': ' . $storable[self::INPUT_FIELD_TITLE] . "\n";
             } else {
                 $dbConn->insert('songs', $storable);
                 if (!($i % 100)) {
                     echo $i;
                 } else {
                     if (!($i % 10)) {
                         echo '.';
                     }
                 }
                 if (!($i % 1000)) {
                     echo "\n";
                 }
                 $i++;
                 $codeStored[$storable['codeNumber']] = true;
             }
         }
     }
     $total = $i - 1;
     echo "\nImported {$total} songs\n";
 }
開發者ID:parsingphase,項目名稱:takeAticket,代碼行數:56,代碼來源:SongLoader.php

示例5: getStoreFields

 /**
  * Get table fields
  *
  * Info: $schemaManager->listTableColumns($this->tableName) doesn't work if fields are geometries!
  *
  * @throws \Doctrine\DBAL\DBALException
  * @return array field names
  */
 public function getStoreFields()
 {
     $schemaManager = $this->connection->getDriver()->getSchemaManager($this->connection);
     $columns = array();
     $sql = $schemaManager->getDatabasePlatform()->getListTableColumnsSQL($this->tableName, $this->connection->getDatabase());
     foreach ($this->connection->fetchAll($sql) as $fieldInfo) {
         $columns[] = $fieldInfo["field"];
     }
     return $columns;
 }
開發者ID:mapbender,項目名稱:data-source,代碼行數:18,代碼來源:DoctrineBaseDriver.php

示例6: createFromConnection

 /**
  * Create a Connection Handler from given Doctrine $connection
  *
  * @param \Doctrine\DBAL\Connection $connection
  *
  * @return \eZ\Publish\Core\Persistence\Doctrine\ConnectionHandler
  */
 public static function createFromConnection(Connection $connection)
 {
     $driver = $connection->getDriver()->getName();
     if ($driver === 'pdo_sqlite') {
         return new ConnectionHandler\SqliteConnectionHandler($connection);
     }
     if ($driver === 'pdo_pgsql') {
         return new ConnectionHandler\PostgresConnectionHandler($connection);
     }
     return new self($connection);
 }
開發者ID:nlescure,項目名稱:ezpublish-kernel,代碼行數:18,代碼來源:ConnectionHandler.php

示例7: datasourceFromDbConnection

 public static function datasourceFromDbConnection(Connection $connection)
 {
     $driverType = $connection->getDriver()->getName();
     switch ($driverType) {
         case 'pdo_mysql':
             return new MySql($connection);
             break;
         case 'pdo_sqlite':
             return new Sqlite($connection);
             break;
         default:
             throw new \InvalidArgumentException("Can't use Db of type {$driverType}");
     }
 }
開發者ID:parsingphase,項目名稱:takeAticket,代碼行數:14,代碼來源:Factory.php

示例8: pathExists

 private function pathExists($path, $workspaceName = null)
 {
     if (null === $workspaceName) {
         $workspaceName = $this->workspaceName;
     }
     if ($this->conn->getDriver() instanceof \Doctrine\DBAL\Driver\PDOMySql\Driver) {
         $query = 'SELECT id FROM phpcr_nodes WHERE path COLLATE utf8_bin = ? AND workspace_name = ?';
     } else {
         $query = 'SELECT id FROM phpcr_nodes WHERE path = ? AND workspace_name = ?';
     }
     if ($nodeId = $this->conn->fetchColumn($query, array($path, $workspaceName))) {
         return $nodeId;
     }
     return false;
 }
開發者ID:viral810,項目名稱:ngSimpleCMS,代碼行數:15,代碼來源:Client.php

示例9: execute

 /**
  * Executes the statement with the currently bound parameters.
  *
  * @param array|null $params
  *
  * @return boolean TRUE on success, FALSE on failure.
  *
  * @throws \Doctrine\DBAL\DBALException
  */
 public function execute($params = null)
 {
     if (is_array($params)) {
         $this->params = $params;
     }
     $logger = $this->conn->getConfiguration()->getSQLLogger();
     if ($logger) {
         $logger->startQuery($this->sql, $this->params, $this->types);
     }
     try {
         $stmt = $this->stmt->execute($params);
     } catch (\Exception $ex) {
         throw DBALException::driverExceptionDuringQuery($this->conn->getDriver(), $ex, $this->sql, $this->conn->resolveParams($this->params, $this->types));
     }
     if ($logger) {
         $logger->stopQuery();
     }
     $this->params = array();
     $this->types = array();
     return $stmt;
 }
開發者ID:ccq18,項目名稱:EduSoho,代碼行數:30,代碼來源:Statement.php

示例10: setUp

 /**
  * Creates a connection to the test database, if there is none yet, and
  * creates the necessary tables.
  *
  * @return void
  */
 protected function setUp()
 {
     $this->setUpDBALTypes();
     $forceCreateTables = false;
     if (!isset(static::$_sharedConn)) {
         static::$_sharedConn = TestUtil::getConnection();
         if (static::$_sharedConn->getDriver() instanceof \Doctrine\DBAL\Driver\PDOSqlite\Driver) {
             $forceCreateTables = true;
         }
     }
     if (isset($GLOBALS['DOCTRINE_MARK_SQL_LOGS'])) {
         if (in_array(static::$_sharedConn->getDatabasePlatform()->getName(), array("mysql", "postgresql"))) {
             static::$_sharedConn->executeQuery('SELECT 1 /*' . get_class($this) . '*/');
         } else {
             if (static::$_sharedConn->getDatabasePlatform()->getName() == "oracle") {
                 static::$_sharedConn->executeQuery('SELECT 1 /*' . get_class($this) . '*/ FROM dual');
             }
         }
     }
     if (!$this->_em) {
         $this->_em = $this->_getEntityManager();
         $this->_schemaTool = new \Doctrine\ORM\Tools\SchemaTool($this->_em);
     }
     $classes = array();
     foreach ($this->_usedModelSets as $setName => $bool) {
         if (!isset(static::$_tablesCreated[$setName])) {
             foreach (static::$_modelSets[$setName] as $className) {
                 $classes[] = $this->_em->getClassMetadata($className);
             }
             static::$_tablesCreated[$setName] = true;
         }
     }
     if ($classes) {
         $this->_schemaTool->createSchema($classes);
     }
     $this->_sqlLoggerStack->enabled = true;
 }
開發者ID:selimcr,項目名稱:servigases,代碼行數:43,代碼來源:OrmFunctionalTestCase.php

示例11: getDriver

 /**
  * @return \Doctrine\DBAL\Driver
  */
 public function getDriver()
 {
     return $this->_connection->getDriver();
 }
開發者ID:Kevin-ZK,項目名稱:vaneDisk,代碼行數:7,代碼來源:ConnectionEventArgs.php

示例12: testGetDriver

 public function testGetDriver()
 {
     $this->assertInstanceOf('Doctrine\\DBAL\\Driver\\PDOMySql\\Driver', $this->_conn->getDriver());
 }
開發者ID:llinder,項目名稱:FrameworkBenchmarks,代碼行數:4,代碼來源:ConnectionTest.php

示例13: getDbMockBuilder

 private function getDbMockBuilder(Connection $db)
 {
     return $this->getMockBuilder('\\Doctrine\\DBAL\\Connection')->setConstructorArgs([$db->getParams(), $db->getDriver(), $db->getConfiguration(), $db->getEventManager()])->enableOriginalConstructor();
 }
開發者ID:gandalf3,項目名稱:bolt,代碼行數:4,代碼來源:StorageTest.php

示例14: fromConnection

 /**
  * Get a vendor-specific selector based on a connection instance.
  *
  * @param  Connection       $connection A connection instance
  * @param  string           $table      The table to select from
  * @return AbstractSelector A selector instance
  * @throws DBALException
  */
 public static function fromConnection(Connection $connection, $table, array $types = [])
 {
     $name = $connection->getDriver()->getName();
     switch ($name) {
         case 'pdo_mysql':
             return new MysqlSelector($connection, $table, $types);
         case 'pdo_sqlite':
             return new SqliteSelector($connection, $table, $types);
         default:
             throw new DBALException("Unsupported database type: {$name}");
     }
 }
開發者ID:glynnforrest,項目名稱:active-doctrine,代碼行數:20,代碼來源:AbstractSelector.php

示例15: setConnectionCollation

 /**
  * Sets the collation for the provided connection.
  *
  * @param  Connection $connection
  * @param  array      $options
  * @throws InvalidArgumentException Occurs if collation is invalid
  */
 private static function setConnectionCollation(Connection $connection, array $options = array())
 {
     if (isset($options['collation'])) {
         try {
             if ('pdo_mysql' === $connection->getDriver()->getName()) {
                 $connection->executeQuery('SET SESSION collation_connection = "' . addslashes($options['collation']) . '";');
             }
         } catch (\Exception $e) {
             throw new InvalidArgumentException(sprintf('Invalid database collation `%s`', $options['collation']), InvalidArgumentException::INVALID_ARGUMENT, $e);
         }
     }
 }
開發者ID:mickaelsteinberg,項目名稱:BackBee,代碼行數:19,代碼來源:EntityManagerCreator.php


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