本文整理汇总了PHP中Zend\Db\Adapter\AdapterInterface::getPlatform方法的典型用法代码示例。如果您正苦于以下问题:PHP AdapterInterface::getPlatform方法的具体用法?PHP AdapterInterface::getPlatform怎么用?PHP AdapterInterface::getPlatform使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Zend\Db\Adapter\AdapterInterface
的用法示例。
在下文中一共展示了AdapterInterface::getPlatform方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: logQuery
/**
* Sends event for a logger to write down query text
* @param mixed $select
*/
protected function logQuery($select)
{
if ($select instanceof Select) {
$platform = $this->dbAdapter->getPlatform();
$query = $select->getSqlString($platform);
} else {
$query = json_encode($select);
}
$this->getEventManager()->trigger(\Application\Utils\Events::LOG_SQL_QUERY, $this, compact('query'));
}
示例2: __construct
public function __construct(AdapterInterface $adapter)
{
$this->adapter = $adapter;
$platform = $adapter->getPlatform();
switch (strtolower($platform->getName())) {
case 'mysql':
$platform = new Mysql\Mysql();
$this->decorators = $platform->decorators;
break;
case 'sqlserver':
$platform = new SqlServer\SqlServer();
$this->decorators = $platform->decorators;
break;
case 'oracle':
$platform = new Oracle\Oracle();
$this->decorators = $platform->decorators;
break;
case 'ibm db2':
case 'ibm_db2':
case 'ibmdb2':
$platform = new IbmDb2\IbmDb2();
$this->decorators = $platform->decorators;
default:
}
}
示例3: getSqlStringForSqlObject
/**
* Get sql string using platform or sql object
*
* @param SqlInterface $sqlObject
* @param PlatformInterface $platform
*
* @return string
*/
public function getSqlStringForSqlObject(SqlInterface $sqlObject, PlatformInterface $platform = null)
{
$platform = $platform ?: $this->adapter->getPlatform();
if ($this->sqlPlatform) {
$this->sqlPlatform->setSubject($sqlObject);
return $this->sqlPlatform->getSqlString($platform);
}
return $sqlObject->getSqlString($platform);
}
示例4: prepareStatement
/**
* {@inheritDoc}
*
* @return StatementContainerInterface
*/
public function prepareStatement(AdapterInterface $adapter, StatementContainerInterface $statementContainer)
{
$parameterContainer = $statementContainer->getParameterContainer();
if (!$parameterContainer instanceof ParameterContainer) {
$parameterContainer = new ParameterContainer();
$statementContainer->setParameterContainer($parameterContainer);
}
$statementContainer->setSql($this->buildSqlString($adapter->getPlatform(), $adapter->getDriver(), $parameterContainer));
return $statementContainer;
}
示例5: __construct
public function __construct(AdapterInterface $adapter)
{
$this->adapter = $adapter;
$platform = $adapter->getPlatform();
switch (strtolower($platform->getName())) {
case 'mysql':
$platform = new ZfPlatform\Mysql\Mysql();
$this->decorators = $platform->decorators;
$this->setTypeDecorator('Zend\\Db\\Sql\\Select', new Mysql\SelectDecorator());
break;
case 'sqlserver':
$platform = new ZfPlatform\SqlServer\SqlServer();
$this->decorators = $platform->decorators;
$this->setTypeDecorator('Zend\\Db\\Sql\\Select', new SqlServer\SelectDecorator());
break;
case 'oracle':
$platform = new ZfPlatform\Oracle\Oracle();
$this->decorators = $platform->decorators;
$this->setTypeDecorator('Zend\\Db\\Sql\\Select', new Oracle\SelectDecorator());
break;
default:
}
}
示例6: prepareStatement
/**
* Prepare statement
*
* @param AdapterInterface $adapter
* @param StatementContainerInterface $statementContainer
* @return void
*/
public function prepareStatement(AdapterInterface $adapter, StatementContainerInterface $statementContainer)
{
$driver = $adapter->getDriver();
$platform = $adapter->getPlatform();
$parameterContainer = $statementContainer->getParameterContainer();
if (!$parameterContainer instanceof ParameterContainer) {
$parameterContainer = new ParameterContainer();
$statementContainer->setParameterContainer($parameterContainer);
}
$table = $this->table;
$schema = null;
// create quoted table name to use in insert processing
if ($table instanceof TableIdentifier) {
list($table, $schema) = $table->getTableAndSchema();
}
$table = $platform->quoteIdentifier($table);
if ($schema) {
$table = $platform->quoteIdentifier($schema) . $platform->getIdentifierSeparator() . $table;
}
$columns = array();
$values = array();
foreach ($this->columns as $cIndex => $column) {
$columns[$cIndex] = $platform->quoteIdentifier($column);
if (isset($this->values[$cIndex]) && $this->values[$cIndex] instanceof Expression) {
$exprData = $this->processExpression($this->values[$cIndex], $platform, $driver);
$values[$cIndex] = $exprData->getSql();
$parameterContainer->merge($exprData->getParameterContainer());
} else {
$values[$cIndex] = $driver->formatParameterName($column);
if (isset($this->values[$cIndex])) {
$parameterContainer->offsetSet($column, $this->values[$cIndex]);
} else {
$parameterContainer->offsetSet($column, null);
}
}
}
$sql = sprintf($this->specifications[self::SPECIFICATION_INSERT], $table, implode(', ', $columns), implode(', ', $values));
$statementContainer->setSql($sql);
}
示例7: prepareStatement
/**
* Prepare statement
*
* @param AdapterInterface $adapter
* @param StatementContainerInterface $statementContainer
* @return void
*/
public function prepareStatement(AdapterInterface $adapter, StatementContainerInterface $statementContainer)
{
$driver = $adapter->getDriver();
$platform = $adapter->getPlatform();
$parameterContainer = $statementContainer->getParameterContainer();
if (!$parameterContainer instanceof ParameterContainer) {
$parameterContainer = new ParameterContainer();
$statementContainer->setParameterContainer($parameterContainer);
}
$table = $this->table;
$schema = null;
// create quoted table name to use in update processing
if ($table instanceof TableIdentifier) {
list($table, $schema) = $table->getTableAndSchema();
}
$table = $platform->quoteIdentifier($table);
if ($schema) {
$table = $platform->quoteIdentifier($schema) . $platform->getIdentifierSeparator() . $table;
}
$set = $this->set;
if (is_array($set)) {
$setSql = array();
foreach ($set as $column => $value) {
if ($value instanceof Expression) {
$exprData = $this->processExpression($value, $platform, $driver);
$setSql[] = $platform->quoteIdentifier($column) . ' = ' . $exprData->getSql();
$parameterContainer->merge($exprData->getParameterContainer());
} else {
$setSql[] = $platform->quoteIdentifier($column) . ' = ' . $driver->formatParameterName($column);
$parameterContainer->offsetSet($column, $value);
}
}
$set = implode(', ', $setSql);
}
$sql = sprintf($this->specifications[static::SPECIFICATION_UPDATE], $table, $set);
// process where
if ($this->where->count() > 0) {
$whereParts = $this->processExpression($this->where, $platform, $driver, 'where');
$parameterContainer->merge($whereParts->getParameterContainer());
$sql .= ' ' . sprintf($this->specifications[static::SPECIFICATION_WHERE], $whereParts->getSql());
}
$statementContainer->setSql($sql);
}
示例8: buildSqlString
/**
* @param SqlInterface $sqlObject
* @param AdapterInterface $adapter
*
* @return string
*
* @throws Exception\InvalidArgumentException
*/
public function buildSqlString(SqlInterface $sqlObject, AdapterInterface $adapter = null)
{
return $this->sqlPlatform->setSubject($sqlObject)->getSqlString($adapter ? $adapter->getPlatform() : $this->adapter->getPlatform());
}
示例9: prepareStatement
/**
* Prepare the delete statement
*
* @param AdapterInterface $adapter
* @param StatementContainerInterface $statementContainer
* @return void
*/
public function prepareStatement(AdapterInterface $adapter, StatementContainerInterface $statementContainer)
{
$driver = $adapter->getDriver();
$platform = $adapter->getPlatform();
$parameterContainer = $statementContainer->getParameterContainer();
if (!$parameterContainer instanceof ParameterContainer) {
$parameterContainer = new ParameterContainer();
$statementContainer->setParameterContainer($parameterContainer);
}
$table = $this->table;
$schema = null;
// create quoted table name to use in delete processing
if ($table instanceof TableIdentifier) {
list($table, $schema) = $table->getTableAndSchema();
}
$table = $platform->quoteIdentifier($table);
if ($schema) {
$table = $platform->quoteIdentifier($schema) . $platform->getIdentifierSeparator() . $table;
}
$sql = sprintf($this->specifications[static::SPECIFICATION_DELETE], $table);
// process where
if ($this->where->count() > 0) {
$whereParts = $this->processExpression($this->where, $platform, $driver, 'where');
$parameterContainer->merge($whereParts->getParameterContainer());
$sql .= ' ' . sprintf($this->specifications[static::SPECIFICATION_WHERE], $whereParts->getSql());
}
$statementContainer->setSql($sql);
}
示例10: prepareStatement
/**
* Prepare statement
*
* @param AdapterInterface $adapter
* @param StatementContainerInterface $statementContainer
* @return void
*/
public function prepareStatement(AdapterInterface $adapter, StatementContainerInterface $statementContainer)
{
// ensure statement has a ParameterContainer
$parameterContainer = $statementContainer->getParameterContainer();
if (!$parameterContainer instanceof ParameterContainer) {
$parameterContainer = new ParameterContainer();
$statementContainer->setParameterContainer($parameterContainer);
}
$sqls = array();
$parameters = array();
$platform = $adapter->getPlatform();
$driver = $adapter->getDriver();
foreach ($this->specifications as $name => $specification) {
$parameters[$name] = $this->{'process' . $name}($platform, $driver, $parameterContainer, $sqls, $parameters);
if ($specification && is_array($parameters[$name])) {
$sqls[$name] = $this->createSqlFromSpecificationAndParameters($specification, $parameters[$name]);
}
}
$sql = implode(' ', $sqls);
$statementContainer->setSql($sql);
return;
}
示例11: resolvePlatform
/**
* @param null|PlatformInterface|AdapterInterface $adapterOrPlatform
*
* @return PlatformInterface
*
* @throws Exception\InvalidArgumentException
*/
protected function resolvePlatform($adapterOrPlatform)
{
if (!$adapterOrPlatform) {
return $this->getDefaultPlatform();
}
if ($adapterOrPlatform instanceof AdapterInterface) {
return $adapterOrPlatform->getPlatform();
}
if ($adapterOrPlatform instanceof PlatformInterface) {
return $adapterOrPlatform;
}
throw new Exception\InvalidArgumentException(sprintf('$adapterOrPlatform should be null, %s, or %s', 'Zend\\Db\\Adapter\\AdapterInterface', 'Zend\\Db\\Adapter\\Platform\\PlatformInterface'));
}
示例12: prepareStatement
/**
* @param AdapterInterface $adapter
* @param StatementContainerInterface $statementContainer
* @return void
*/
public function prepareStatement(AdapterInterface $adapter, StatementContainerInterface $statementContainer)
{
$driver = $adapter->getDriver();
$platform = $adapter->getPlatform();
$parameterContainer = $statementContainer->getParameterContainer();
if (!$parameterContainer instanceof ParameterContainer) {
$parameterContainer = new ParameterContainer();
$statementContainer->setParameterContainer($parameterContainer);
}
$function = $platform->quoteIdentifierChain($this->function);
$resultKey = $platform->quoteIdentifier($this->resultKey);
$arguments = array();
$i = 0;
foreach ($this->arguments as $argument) {
if ($argument instanceof Expression) {
$exprData = $this->processExpression($argument, $platform, $driver);
$arguments[] = $exprData->getSql();
$parameterContainer->merge($exprData->getParameterContainer());
} else {
$parameterName = 'func_arg_' . $i++;
$arguments[] = $driver->formatParameterName($parameterName);
$parameterContainer->offsetSet($parameterName, $argument);
}
}
$sql = sprintf($this->specifications[$this->mode], $function, implode(', ', $arguments), $resultKey);
$statementContainer->setSql($sql);
}
示例13: __invoke
public function __invoke($value = null)
{
return 'Platform name ' . $this->dbAdapter->getPlatform()->getName();
}
示例14: prepareStatement
/**
* Prepare statement
*
* @param AdapterInterface $adapter
* @param StatementContainerInterface $statementContainer
* @return void
*/
public function prepareStatement(AdapterInterface $adapter, StatementContainerInterface $statementContainer)
{
// ensure statement has a ParameterContainer
$parameterContainer = $statementContainer->getParameterContainer();
if (!$parameterContainer instanceof ParameterContainer) {
$parameterContainer = new ParameterContainer();
$statementContainer->setParameterContainer($parameterContainer);
}
$sqls = array();
$sqls[self::SHOW] = sprintf($this->specifications[static::SHOW], $this->show);
$likePart = $this->processLike($adapter->getPlatform(), $adapter->getDriver(), $parameterContainer);
if (is_array($likePart)) {
$sqls[self::LIKE] = $this->createSqlFromSpecificationAndParameters($this->specifications[static::LIKE], $likePart);
}
$sql = implode(' ', $sqls);
$statementContainer->setSql($sql);
return;
}
示例15: prepareStatement
/**
* Prepare statement
*
* @param AdapterInterface $adapter
* @param StatementContainerInterface $statementContainer
* @return void
*/
public function prepareStatement(AdapterInterface $adapter, StatementContainerInterface $statementContainer)
{
$driver = $adapter->getDriver();
$platform = $adapter->getPlatform();
$parameterContainer = $statementContainer->getParameterContainer();
if (!$parameterContainer instanceof ParameterContainer) {
$parameterContainer = new ParameterContainer();
$statementContainer->setParameterContainer($parameterContainer);
}
$table = $this->table;
$table = $platform->quoteIdentifier($table);
$set = $this->set;
$setSql = array();
foreach ($set as $column => $value) {
if ($value instanceof Predicate\Expression) {
$exprData = $this->processExpression($value, $platform, $driver);
$setSql[] = $platform->quoteIdentifier($column) . ' = ' . $exprData->getSql();
$parameterContainer->merge($exprData->getParameterContainer());
} else {
$setSql[] = $platform->quoteIdentifier($column) . ' = ' . $driver->formatParameterName($column);
$parameterContainer->offsetSet($column, $value);
}
}
$set = implode(', ', $setSql);
$sql = sprintf($this->specifications[self::SPECIFICATION_UPDATE], $table, $set);
// Process where
if ($this->where->count() > 0) {
$whereParts = $this->processExpression($this->where, $platform, $driver, 'where');
$parameterContainer->merge($whereParts->getParameterContainer());
$sql .= ' ' . sprintf($this->specifications[self::SPECIFICATION_WHERE], $whereParts->getSql());
}
// Process option
$optionParts = $this->processOption($platform, $driver, $parameterContainer);
if (is_array($optionParts)) {
$sql .= ' ' . $this->createSqlFromSpecificationAndParameters($this->specifications[self::SPECIFICATION_OPTION], $optionParts);
}
$statementContainer->setSql($sql);
}