当前位置: 首页>>代码示例>>PHP>>正文


PHP Adapter::getDriver方法代码示例

本文整理汇总了PHP中Zend\Db\Adapter\Adapter::getDriver方法的典型用法代码示例。如果您正苦于以下问题:PHP Adapter::getDriver方法的具体用法?PHP Adapter::getDriver怎么用?PHP Adapter::getDriver使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Zend\Db\Adapter\Adapter的用法示例。


在下文中一共展示了Adapter::getDriver方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: getConnection

 /**
  * Get Database Connection
  *
  * @return PHPUnit_Extensions_Database_DB_IDatabaseConnection
  */
 public function getConnection()
 {
     if (!$this->connection) {
         $dbConfig = array('driver' => 'pdo', 'dsn' => 'mysql:dbname=ipc2013.testing.test;host=localhost;charset=utf8', 'user' => 'ipc2013', 'pass' => 'ipc2013');
         $this->adapter = new Adapter($dbConfig);
         $this->connection = $this->createDefaultDBConnection($this->adapter->getDriver()->getConnection()->getResource(), 'ipc2013.testing.test');
     }
     return $this->connection;
 }
开发者ID:huanhuashengling,项目名称:ipc2013-testing,代码行数:14,代码来源:CustomerTableDatabaseTest.php

示例2: loadConfig

 /**
  * Load config from db-adapter
  *
  * @param \Zend\Db\Adapter\Adapter $db
  * @return array
  */
 protected function loadConfig()
 {
     if (empty($this->dbAdapter)) {
         return $this->config;
     }
     $platform = $this->dbAdapter->getPlatform();
     $driver = $this->dbAdapter->getDriver();
     $query = $this->dbAdapter->query('
         SELECT ' . $platform->quoteIdentifier('value') . '
           FROM ' . $platform->quoteIdentifier('settings') . '
          WHERE ' . $platform->quoteIdentifier('key') . '
              = ' . $platform->quoteValue('ini-cache') . '
            AND ' . $platform->quoteIdentifier('type') . '
              = ' . $platform->quoteValue('ini-cache') . '
          LIMIT 1
     ');
     $this->config = array();
     $result = $query->execute();
     if ($result->getAffectedRows() > 0) {
         foreach ($result as $cache) {
             $this->config = ArrayUtils::merge($this->config, (array) unserialize($cache['value']));
         }
     } else {
         $query = $this->dbAdapter->query('
             SELECT ' . $platform->quoteIdentifier('key') . ',
                    ' . $platform->quoteIdentifier('value') . '
               FROM ' . $platform->quoteIdentifier('settings') . '
              WHERE ' . $platform->quoteIdentifier('type') . '
                  = ' . $platform->quoteValue('ini') . '
         ');
         foreach ($query->execute() as $pair) {
             $key = (string) $pair['key'];
             $value = (string) $pair['value'];
             $entry = array();
             $curr =& $entry;
             foreach (explode('.', $key) as $sub) {
                 $curr[$sub] = null;
                 $curr =& $curr[$sub];
             }
             $curr = $value;
             $this->config = ArrayUtils::merge($this->config, $entry);
         }
         $query = $this->dbAdapter->query('
             INSERT INTO ' . $platform->quoteIdentifier('settings') . '
                         ( ' . $platform->quoteIdentifier('key') . ',
                           ' . $platform->quoteIdentifier('value') . ',
                           ' . $platform->quoteIdentifier('type') . ' )
                  VALUES ( ' . $driver->formatParameterName('key') . ',
                           ' . $driver->formatParameterName('value') . ',
                           ' . $driver->formatParameterName('type') . ' )
         ');
         $query->execute(array('key' => 'ini-cache', 'value' => serialize($this->config), 'type' => 'ini-cache'));
     }
     $this->dbAdapter = null;
     return $this->config;
 }
开发者ID:gridguyz,项目名称:zork,代码行数:62,代码来源:LoaderListener.php

示例3: save

 public function save(Queue $queue)
 {
     if ($queue->getId()) {
         $query = $this->dbAdapter->query('UPDATE `queues` SET `name` = :name WHERE `id = :id`');
         $query->execute($queue->getArrayCopy());
     } else {
         $query = $this->dbAdapter->query("INSERT INTO `queues` (`name`) VALUES (:name)");
         $query->execute(['name' => $queue->getName()]);
         $queue->setId($this->dbAdapter->getDriver()->getLastGeneratedValue());
     }
     return $queue;
 }
开发者ID:dragonmantank,项目名称:dockerfordevs-app,代码行数:12,代码来源:QueueService.php

示例4: factory

 /**
  * @param array|\Zend\Db\Adapter\Driver\DriverInterface $config
  * @throws UnsupportedDriverException
  * @return \Zend\Db\Adapter\Adapter
  */
 public static function factory($config)
 {
     $platform = new SphinxQL();
     $adapter = new ZendDBAdapter($config, $platform);
     $driver = $adapter->getDriver();
     // Check driver
     if ($driver instanceof ZendPdoDriver && $driver->getDatabasePlatformName(ZendPdoDriver::NAME_FORMAT_CAMELCASE) == 'Mysql') {
         $driver->registerStatementPrototype(new PdoStatement());
     } elseif (!$driver instanceof ZendMysqliDriver) {
         $class = get_class($driver);
         throw new UnsupportedDriverException($class . ' not supported. Use Zend\\Db\\Adapter\\Driver\\Pdo\\Pdo or Zend\\Db\\Adapter\\Driver\\Mysqli\\Mysqli');
     }
     $platform->setDriver($adapter->getDriver());
     return $adapter;
 }
开发者ID:ripaclub,项目名称:sphinxsearch,代码行数:20,代码来源:AdapterServiceFactory.php

示例5: processCommandTask

 /**
  * Process the command
  *
  * @return integer
  */
 public function processCommandTask()
 {
     // load autoload configuration from project
     $config = ConfigFactory::fromFiles(glob($this->params->projectConfigDir . '/autoload/{,*.}{global,development,local}.php', GLOB_BRACE));
     // check for db config
     if (empty($config) || !isset($config['db'])) {
         $this->console->writeFailLine('task_crud_check_db_connection_no_config');
         return 1;
     }
     // create db adapter instance
     try {
         $dbAdapter = new Adapter($config['db']);
     } catch (InvalidArgumentException $e) {
         $this->console->writeFailLine('task_crud_check_db_connection_config_inconsistent');
         return 1;
     }
     // connect to database
     try {
         $connection = $dbAdapter->getDriver()->getConnection()->connect();
     } catch (RuntimeException $e) {
         $this->console->writeFailLine('task_crud_check_db_connection_failed');
         return 1;
     }
     $this->params->dbAdapter = $dbAdapter;
     return 0;
 }
开发者ID:pgiacometto,项目名称:zf2rapid,代码行数:31,代码来源:CheckDbConnection.php

示例6: executeRawQuery

 /**
  * Simple query executor, expects results and returns them as an assoc array
  * @param $query
  * @param array $params
  * @return array
  * @throws \Exception
  */
 public function executeRawQuery($query, array $params = array())
 {
     $this->logQuery($this->fixTableName($query), $params);
     try {
         $this->result = $this->_adapter->query($this->fixTableName($query), $params);
     } catch (\Exception $e) {
         $this->result = new ResultSet(ResultSet::TYPE_ARRAY, []);
         $mysqli = $this->_adapter->getDriver()->getConnection()->getResource();
         error_log("ERROR: ADB : executeRawQuery");
         error_log("Engine message: " . isset($mysqli->error) ? $mysqli->error : "No message available");
         error_log($e->getMessage());
         error_log("query: " . $this->getFullQuery($query, $params));
         error_log($e->getTraceAsString());
         $throw = true;
         if (isset($this->_conf['suppress-exceptions'])) {
             if ($this->_conf['suppress-exceptions']) {
                 $throw = false;
             }
         }
         if (!isset($this->_conf['throw-engine-message'])) {
             // throw engine message by default
             $this->_conf['throw-engine-message'] = true;
         }
         if ($throw) {
             if (isset($mysqli->error) && $this->_conf['throw-engine-message'] && !empty($mysqli->error)) {
                 throw new \Exception($mysqli->error);
             } else {
                 throw $e;
             }
         }
     }
     $this->safeDropCache($query);
     return $this->result;
 }
开发者ID:ArchangelDesign,项目名称:ArchangelDB2,代码行数:41,代码来源:ADB2.php

示例7: dropSchemaFor

 /**
  * Drops a stream table
  *
  * Use this function with caution. All your events will be lost! But it can be useful in migration scenarios.
  *
  * @param StreamName $streamName
  * @param bool $returnSql
  * @return string|null Whether $returnSql is true or not function will return generated sql or execute it directly
  */
 public function dropSchemaFor(StreamName $streamName, $returnSql = false)
 {
     $dropTable = new DropTable($this->getTable($streamName));
     if ($returnSql) {
         return $dropTable->getSqlString($this->dbAdapter->getPlatform());
     }
     $this->dbAdapter->getDriver()->getConnection()->execute($dropTable->getSqlString($this->dbAdapter->getPlatform()));
 }
开发者ID:prooph,项目名称:event-store-zf2-adapter,代码行数:17,代码来源:Zf2EventStoreAdapter.php

示例8: create

 /**
  * @return bool $successfulCreate
  */
 protected function create() : bool
 {
     $insert = $this->sql->insert($this->getTablename());
     $id = $this->adapter->getDriver()->getConnection()->getLastGeneratedValue();
     $this->load($id);
     $success = true;
     return $success;
 }
开发者ID:geolysis,项目名称:gz3-base,代码行数:11,代码来源:AbstractManager.php

示例9: rollbackTransaction

 public function rollbackTransaction()
 {
     self::$transactionCounter--;
     if (!self::$transactionCounter) {
         $connection = $this->adapter->getDriver()->getConnection();
         $connection->rollback();
     }
 }
开发者ID:jiromm,项目名称:zf3-skeleton-application,代码行数:8,代码来源:CommonTableGateway.php

示例10: dropSqliteSchema

 protected function dropSqliteSchema(array $streams)
 {
     foreach ($streams as $stream) {
         $streamSql = 'DROP TABLE IF EXISTS ' . $this->getTable($stream);
         $this->dbAdatper->getDriver()->getConnection()->execute($streamSql);
     }
     $snapshotSql = 'DROP TABLE IF EXISTS snapshot';
     $this->dbAdatper->getDriver()->getConnection()->execute($snapshotSql);
 }
开发者ID:malocher,项目名称:zf2-event-store-module,代码行数:9,代码来源:Zf2EventStoreAdapter.php

示例11: insert

 /**
  * Insert
  * 
  * @param  array $set
  * @return int
  */
 public function insert($set)
 {
     $insert = $this->sql->insert();
     $insert->values($set);
     $statement = $this->sql->prepareStatementForSqlObject($insert);
     $result = $statement->execute();
     $this->lastInsertValue = $this->adapter->getDriver()->getConnection()->getLastGeneratedValue();
     return $result->getAffectedRows();
 }
开发者ID:rikaix,项目名称:zf2,代码行数:15,代码来源:TableGateway.php

示例12: processExpression

 protected function processExpression(ExpressionInterface $expression, PlatformInterface $platform, Adapter $adapter = null, $namedParameterPrefix = null)
 {
     // static counter for the number of times this method was invoked across the PHP runtime
     static $runtimeExpressionPrefix = 0;
     if ($adapter && (!is_string($namedParameterPrefix) || $namedParameterPrefix == '')) {
         $namedParameterPrefix = sprintf('expr%04dParam', ++$runtimeExpressionPrefix);
     }
     $sql = '';
     $statementContainer = new StatementContainer();
     $parameterContainer = $statementContainer->getParameterContainer();
     // initialize variables
     $parts = $expression->getExpressionData();
     $expressionParamIndex = 1;
     foreach ($parts as $part) {
         // if it is a string, simply tack it onto the return sql "specification" string
         if (is_string($part)) {
             $sql .= $part;
             continue;
         }
         if (!is_array($part)) {
             throw new Exception\RuntimeException('Elements returned from getExpressionData() array must be a string or array.');
         }
         // process values and types (the middle and last position of the expression data)
         $values = $part[1];
         $types = isset($part[2]) ? $part[2] : array();
         foreach ($values as $vIndex => $value) {
             if (isset($types[$vIndex]) && $types[$vIndex] == ExpressionInterface::TYPE_IDENTIFIER) {
                 $values[$vIndex] = $platform->quoteIdentifierInFragment($value);
             } elseif (isset($types[$vIndex]) && $types[$vIndex] == ExpressionInterface::TYPE_VALUE) {
                 // if prepareType is set, it means that this particular value must be
                 // passed back to the statement in a way it can be used as a placeholder value
                 if ($adapter) {
                     $name = $namedParameterPrefix . $expressionParamIndex++;
                     $parameterContainer->offsetSet($name, $value);
                     $values[$vIndex] = $adapter->getDriver()->formatParameterName($name);
                     continue;
                 }
                 // if not a preparable statement, simply quote the value and move on
                 $values[$vIndex] = $platform->quoteValue($value);
             } elseif (isset($types[$vIndex]) && $types[$vIndex] == ExpressionInterface::TYPE_LITERAL) {
                 $values[$vIndex] = $value;
             } elseif (isset($types[$vIndex]) && $types[$vIndex] == ExpressionInterface::TYPE_SELECT) {
                 // process sub-select
                 if ($adapter) {
                     $values[$vIndex] = '(' . $this->processSubSelect($value, $platform, $adapter, $statementContainer->getParameterContainer()) . ')';
                 } else {
                     $values[$vIndex] = '(' . $this->processSubSelect($value, $platform) . ')';
                 }
             }
         }
         // after looping the values, interpolate them into the sql string (they might be placeholder names, or values)
         $sql .= vsprintf($part[0], $values);
     }
     $statementContainer->setSql($sql);
     return $statementContainer;
 }
开发者ID:haoyanfei,项目名称:zf2,代码行数:56,代码来源:AbstractSql.php

示例13: __construct

 /**
  * @param \Zend\Db\Adapter\Adapter $adapter
  */
 public function __construct($adapter)
 {
     $dbConfig = $adapter->getDriver()->getConnection()->getConnectionParameters();
     if (isset($dbConfig['dsn'])) {
         $data = EhrlichAndreas_Util_Dsn::parseDsn($dbConfig['dsn']);
         foreach ($data as $key => $value) {
             $dbConfig[$key] = $value;
         }
         $data = EhrlichAndreas_Util_Dsn::parseUri($dbConfig['dsn']);
         if (isset($data[0])) {
             $dbConfig['adapter'] = ucfirst($data[0]);
         }
         if (isset($dbConfig['adapter']) && $dbConfig['driver']) {
             $dbConfig['adapter'] = $dbConfig['driver'] . '_' . $dbConfig['adapter'];
         }
     }
     $this->adapter = EhrlichAndreas_Db_Db::factory($dbConfig);
     $this->adapter->setConnection($adapter->getDriver()->getConnection()->getResource());
 }
开发者ID:ehrlichandreas,项目名称:ehrlichandreas1-db,代码行数:22,代码来源:Adapter.php

示例14: selectCategoryOptions

 public function selectCategoryOptions()
 {
     $adapter = new Adapter(array('driver' => 'mysqli', 'host' => 'localhost', 'port' => '3306', 'dbname' => 'zndemo', 'username' => 'root', 'password' => ''));
     $result = $adapter->getDriver()->getConnection()->execute('select id,name from categories where status=1');
     $selectData = array(0 => '--Select Category--');
     foreach ($result as $res) {
         $selectData[$res['id']] = $res['name'];
     }
     return $selectData;
 }
开发者ID:anillaogi016,项目名称:zend-admin,代码行数:10,代码来源:AlbumForm.php

示例15: create

 public function create(array $data)
 {
     $sql = new Sql($this->adapter);
     $this->adapter->getDriver()->getConnection()->beginTransaction();
     $insert = $sql->insert('places');
     $insert->values(['name' => $data['name'], 'latitude' => $data['latitude'], 'longitude' => $data['longitude']]);
     $query = $sql->getSqlStringForSqlObject($insert);
     /** @var Result $results */
     $results = $this->adapter->query($query, Adapter::QUERY_MODE_EXECUTE);
     $placeId = $results->getGeneratedValue();
     foreach ($data['types'] as $typeId) {
         $insert = $sql->insert('places_place_types');
         $insert->values(['place_id' => $placeId, 'place_type_id' => $typeId]);
         $q = $sql->getSqlStringForSqlObject($insert);
         $this->adapter->query($q, Adapter::QUERY_MODE_EXECUTE);
     }
     $this->adapter->getDriver()->getConnection()->commit();
     return $placeId;
 }
开发者ID:baptistecosta,项目名称:mon-partenaire,代码行数:19,代码来源:PlaceMapper.php


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