当前位置: 首页>>代码示例>>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;未经允许,请勿转载。