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


PHP Adapter::getPlatform方法代码示例

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


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

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

示例2: prefixedColumns

 /**
  * Add table prefixed columns, will automatically
  * quote table parts identifiers found in the column name.
  * It provides an alternative for defining columns from multiple/joined
  * table in one go.
  *
  * <code>
  * $select->from(array('p' =>'product')
  *        ->prefixedColumns(array('product_title' => 'p.title'));
  * </code>
  * Possible valid states:
  *   array(value, ...)
  *     value can be strings or Expression objects
  *
  *   array(string => value, ...)
  *     key string will be use as alias,
  *     value can be string or Expression objects
  *
  * @throws Exception\InvalidArgumentException when usage not correct
  * @param  array $columns
  * @return Select
  */
 public function prefixedColumns(array $columns)
 {
     $pf = $this->adapter->getPlatform();
     $identifierSeparator = $pf->getIdentifierSeparator();
     $names = array();
     $cols = array();
     foreach ($columns as $alias => $column) {
         if (is_string($column)) {
             if (strpos($column, self::SQL_STAR) !== false) {
                 $msg = __METHOD__ . " Invalid argument, prefixedColumn() does not accept sql * column specification";
                 throw new Exception\InvalidArgumentException($msg);
             }
             $parts = explode($identifierSeparator, $column);
             if (count($parts) > 1) {
                 $quotedParts = array();
                 foreach ($parts as $part) {
                     $quotedParts[] = $pf->quoteIdentifier($part);
                 }
                 // to remove PHPAnalyzer warnings
                 //var_dump($quotedParts[count($quotedParts)-1]);
                 //die();
                 $last_part = $parts[count($parts) - 1];
                 if (!is_string($alias)) {
                     $alias = $last_part;
                 }
                 if (in_array($alias, $names)) {
                     $msg = __METHOD__ . ": Invalid argument, multiple columns have the same alias ({$alias})";
                     throw new Exception\InvalidArgumentException($msg);
                 }
                 $names[] = $alias;
                 $cols[$alias] = new Expression(join($identifierSeparator, $quotedParts));
             } else {
                 if (in_array($alias, $names)) {
                     $msg = __METHOD__ . ": Invalid argument, multiple columns have the same alias ({$alias})";
                     throw new Exception\InvalidArgumentException($msg);
                 }
                 $cols[$alias] = $column;
                 $names[] = $alias;
             }
         } else {
             if (in_array($alias, $names)) {
                 $msg = __METHOD__ . ": Invalid argument, multiple columns have the same alias ({$alias})";
                 throw new Exception\InvalidArgumentException($msg);
             }
             $cols[$alias] = $column;
             $names[] = $alias;
         }
     }
     $this->columns($cols);
     return $this;
 }
开发者ID:robocoder,项目名称:solublecomponents,代码行数:73,代码来源:Select.php

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

示例4: createSourceFromAdapter

 /**
  * Create source from adapter
  * 
  * @param  Adapter $adapter
  * @return Source\InformationSchemaMetadata 
  */
 protected function createSourceFromAdapter(Adapter $adapter)
 {
     switch ($adapter->getPlatform()->getName()) {
         case 'MySQL':
         case 'SQLServer':
             return new Source\InformationSchemaMetadata($adapter);
         case 'SQLite':
             return new Source\SqliteMetadata($adapter);
     }
     throw new \Exception('cannot create source from adapter');
 }
开发者ID:rikaix,项目名称:zf2,代码行数:17,代码来源:Metadata.php

示例5: getName

 /**
  * (non-PHPdoc)
  *
  * @see \VisioCrudModeler\Descriptor\AbstractDataSourceDescriptor::getName()
  */
 public function getName()
 {
     if (is_null($this->name)) {
         if ($this->adapter->getPlatform() instanceof \Zend\Db\Adapter\Platform\Mysql) {
             $this->name = $this->currentDatabaseMysql();
         } else {
             throw new \RuntimeException('Automatic database name resolving is not supported for platform: ' . get_class($this->adapter->getPlatform()));
         }
     }
     return $this->name;
 }
开发者ID:renatosalvatori,项目名称:visio-crud-zf2,代码行数:16,代码来源:DbDataSourceDescriptor.php

示例6: _authenticateCreateSelect

 /**
  * _authenticateCreateSelect() - This method creates a Zend\Db\Sql\Select object that
  * is completely configured to be queried against the database.
  *
  * @return DbSelect
  */
 protected function _authenticateCreateSelect()
 {
     // build credential expression
     if (empty($this->credentialTreatment) || strpos($this->credentialTreatment, '?') === false) {
         $this->credentialTreatment = '?';
     }
     $credentialExpression = new Expression('(CASE WHEN ' . $this->zendDb->getPlatform()->quoteIdentifier($this->credentialColumn) . ' = ' . $this->credentialTreatment . ' THEN 1 ELSE 0 END) AS ' . $this->zendDb->getPlatform()->quoteIdentifier('zend_auth_credential_match'));
     // get select
     $dbSelect = clone $this->getDbSelect();
     $dbSelect->from($this->tableName)->columns(array('*', $credentialExpression))->where($this->zendDb->getPlatform()->quoteIdentifier($this->identityColumn) . ' = ?');
     return $dbSelect;
 }
开发者ID:nuklehed,项目名称:zf2,代码行数:18,代码来源:DbTable.php

示例7: setAdapter

 /**
  * Sets the DB adapter.
  * 
  * @param Adapter $dbAdapter
  */
 public function setAdapter(Adapter $dbAdapter)
 {
     $this->dbAdapter = $dbAdapter;
     /*
      * temp fix
      */
     $driver = $this->dbAdapter->getDriver();
     $driver->getConnection()->connect();
     $this->dbAdapter->getPlatform()->setDriver($driver);
     /* --- */
     $this->setSqlFromAdapter($dbAdapter);
 }
开发者ID:ivan-novakov,项目名称:zf2-openid-connect-server-module,代码行数:17,代码来源:MysqlLite.php

示例8: createSourceFromAdapter

 /**
  * Automatically create source from adapter
  *
  * @throws Exception\UnsupportedDriverException
  * @param \Zend\Db\Adapter\Adapter $adapter
  * @param string $schema database schema to use or null to current schema defined by the adapter
  * @return \Soluble\Db\Metadata\Source\AbstractSource
  */
 protected function createSourceFromAdapter(Adapter $adapter, $schema = null)
 {
     $adapter_name = strtolower($adapter->getPlatform()->getName());
     switch ($adapter_name) {
         case 'mysql':
             $source = new Source\Mysql\InformationSchema($adapter, $schema);
             break;
         default:
             throw new Exception\UnsupportedDriverException("Currently only MySQL is supported, driver set '{$adapter_name}'");
     }
     return $source;
 }
开发者ID:robocoder,项目名称:solublecomponents,代码行数:20,代码来源:Metadata.php

示例9: __construct

 public function __construct(Adapter $adapter)
 {
     $this->adapter = $adapter;
     $platform = $adapter->getPlatform();
     switch (strtolower($platform->getName())) {
         case 'sqlserver':
             $platform = new SqlServer\SqlServer();
             $this->decorators = $platform->decorators;
             break;
         default:
     }
 }
开发者ID:haoyanfei,项目名称:zf2,代码行数:12,代码来源:Platform.php

示例10: createService

 /**
  * Create db adapter service
  *
  * @param ServiceLocatorInterface $serviceLocator
  * @return Adapter
  */
 public function createService(ServiceLocatorInterface $serviceLocator)
 {
     $config = $serviceLocator->get('Config');
     $result = new Adapter($config['db']);
     if (defined('SCPPER_DEBUG')) {
         $profiler = new \Zend\Db\Adapter\Profiler\Profiler();
         $result->setProfiler($profiler);
         if ($result->getPlatform()->getName() === 'MySQL') {
             $result->query('SET SESSION query_cache_type=0;', Adapter::QUERY_MODE_EXECUTE);
         }
     }
     return $result;
 }
开发者ID:FiftyNine,项目名称:ScpperDB,代码行数:19,代码来源:DbAdapterFactory.php

示例11: setOptions

 /**
  * Set the db adapter options
  * @param array $options
  */
 protected function setOptions(array $options)
 {
     if (!array_key_exists('adapter', $options) || !array_key_exists('table', $options) || !array_key_exists('column_key', $options) || !array_key_exists('column_value', $options)) {
         throw new Exception\InvalidArgumentException('Db adapter options must be defined "adapter", "table", "column_key" and "column_value" keys.');
     }
     if (!$options['adapter'] instanceof Adapter) {
         throw new Exception\InvalidArgumentException('Db adapter must be an instance of Zend\\Db\\Adapter\\Adapter.');
     }
     $this->adapter = $options['adapter'];
     $options['table'] = $this->adapter->getPlatform()->quoteIdentifier($options['table']);
     $options['column_key'] = $this->adapter->getPlatform()->quoteIdentifier($options['column_key']);
     $options['column_value'] = $this->adapter->getPlatform()->quoteIdentifier($options['column_value']);
     $this->options = $options;
     return $this;
 }
开发者ID:cityware,项目名称:city-shared-memory,代码行数:19,代码来源:Db.php

示例12: createSourceFromAdapter

 protected function createSourceFromAdapter(Adapter $adapter)
 {
     switch ($adapter->getPlatform()->getName()) {
         case 'MySQL':
             return new Source\MysqlMetadata($adapter);
         case 'SQLServer':
             return new Source\SqlServerMetadata($adapter);
         case 'SQLite':
             return new Source\SqliteMetadata($adapter);
         case 'PostgreSQL':
             return new Source\PostgresqlMetadata($adapter);
         case 'Oracle':
             return new Source\OracleMetadata($adapter);
     }
     throw new \Exception('cannot create source from adapter');
 }
开发者ID:railsphp,项目名称:framework,代码行数:16,代码来源:Metadata.php

示例13: configure

 /**
  * Setup services which depends on the db
  *
  * @param   \Zend\Db\Adapter\Adapter $db
  * @return  \Zend\Db\Adapter\Adapter
  */
 public function configure(DbAdapter $db)
 {
     $sm = $this->getServiceLocator();
     $platform = $db->getPlatform();
     $driver = $db->getDriver();
     $domain = strtolower($this->getDomain());
     $query = $db->query('
         SELECT *
           FROM ' . $platform->quoteIdentifier('_central') . '.' . $platform->quoteIdentifier('fulldomain') . '
          WHERE LOWER( ' . $platform->quoteIdentifier('fulldomain') . ' )
              = LOWER( ' . $driver->formatParameterName('fulldomain') . ' )
     ');
     $result = $query->execute(array('fulldomain' => $domain));
     if ($result->getAffectedRows() > 0) {
         foreach ($result as $data) {
             $info = new SiteInfo(array_merge($data, array('scheme' => $this->getScheme(), 'port' => $this->getPort())));
             $sm->setService('SiteInfo', $info);
             $driver->getConnection()->setCurrentSchema($info->getSchema());
             return $db;
         }
     } else {
         $parts = explode('.', $domain);
         $subParts = array();
         $mainDomain = false;
         while (count($parts) > 2) {
             $subParts[] = array_shift($parts);
             $mainDomain = implode('.', $parts);
             $result = $query->execute(array('fulldomain' => $mainDomain));
             if ($result->getAffectedRows() > 0) {
                 break;
             }
             $mainDomain = false;
         }
         if ($mainDomain) {
             $sm->setService('RedirectToDomain', new RedirectionService($this->getScheme(), $mainDomain, $this->getPort(), sprintf('sub-domain "%s" not found', implode('.', $subParts)), true));
         } else {
             $config = $driver->getConnection()->getConnectionParameters();
             if (empty($config['defaultDomain'])) {
                 throw new Exception\InvalidArgumentException('Domain not found, and default domain not set');
             } else {
                 $sm->setService('RedirectToDomain', new RedirectionService($this->getScheme(), $config['defaultDomain'], $this->getPort(), 'domain not found', false));
             }
         }
     }
     return $db;
 }
开发者ID:gridguyz,项目名称:multisite,代码行数:52,代码来源:Multisite.php

示例14: createSourceFromAdapter

 /**
  * Create source from adapter
  *
  * @param  Adapter $adapter
  * @return MetadataInterface
  * @throws InvalidArgumentException If adapter platform name not recognized.
  */
 public static function createSourceFromAdapter(Adapter $adapter)
 {
     $platformName = $adapter->getPlatform()->getName();
     switch ($platformName) {
         case 'MySQL':
             return new MysqlMetadata($adapter);
         case 'SQLServer':
             return new SqlServerMetadata($adapter);
         case 'SQLite':
             return new SqliteMetadata($adapter);
         case 'PostgreSQL':
             return new PostgresqlMetadata($adapter);
         case 'Oracle':
             return new OracleMetadata($adapter);
         default:
             throw new InvalidArgumentException("Unknown adapter platform '{$platformName}'");
     }
 }
开发者ID:zendframework,项目名称:zend-db,代码行数:25,代码来源:Factory.php

示例15: prepareStatement

 /**
  * Prepare statement
  *
  * @param \Zend\Db\Adapter\Adapter $adapter
  * @param \Zend\Db\Adapter\Driver\StatementInterface $statement
  * @return void
  */
 public function prepareStatement(Adapter $adapter, StatementInterface $statement)
 {
     $driver = $adapter->getDriver();
     $platform = $adapter->getPlatform();
     $parameterContainer = $statement->getParameterContainer();
     $prepareType = $driver->getPrepareType();
     $parts = parent::getWhereParts();
     $wherePart = '';
     $whereParamIndex = 1;
     foreach ($parts as $part) {
         if (is_string($part)) {
             $wherePart .= $part;
         } elseif (is_array($part)) {
             $values = $part[1];
             $types = isset($part[2]) ? $part[2] : array();
             foreach ($values as $vIndex => $value) {
                 if (isset($types[$vIndex]) && $types[$vIndex] == self::TYPE_IDENTIFIER) {
                     $values[$vIndex] = $platform->quoteIdentifierInFragment($value);
                 } elseif (isset($types[$vIndex]) && $types[$vIndex] == self::TYPE_VALUE) {
                     if ($prepareType == 'positional') {
                         $parameterContainer->offsetSet(null, $value);
                         $values[$vIndex] = $driver->formatParameterName(null);
                     } elseif ($prepareType == 'named') {
                         $name = 'where' . $whereParamIndex++;
                         $values[$vIndex] = $driver->formatParameterName($name);
                         $parameterContainer->offsetSet($name, $value);
                     }
                 }
             }
             $wherePart .= vsprintf($part[0], $values);
         }
     }
     $sql = $statement->getSql();
     $sql .= sprintf($this->specification, $wherePart);
     $statement->setSql($sql);
 }
开发者ID:bradley-holt,项目名称:zf2,代码行数:43,代码来源:Where.php


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