本文整理汇总了PHP中Doctrine\DBAL\Platforms\AbstractPlatform::getName方法的典型用法代码示例。如果您正苦于以下问题:PHP AbstractPlatform::getName方法的具体用法?PHP AbstractPlatform::getName怎么用?PHP AbstractPlatform::getName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Doctrine\DBAL\Platforms\AbstractPlatform
的用法示例。
在下文中一共展示了AbstractPlatform::getName方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testRequireQueryForServerVersion
public function testRequireQueryForServerVersion()
{
if ($this->platform->getName() != 'informix') {
$this->markTestSkipped('This test only applies to PDO_INFORMIX');
}
$this->assertTrue($this->driverConnection->requiresQueryForServerVersion());
}
示例2: testQuoteSingleIdentifier
/**
* @group DDC-1360
*/
public function testQuoteSingleIdentifier()
{
if ($this->_platform->getName() == "mssql") {
$this->markTestSkipped('Not working this way on mssql.');
}
$c = $this->_platform->getIdentifierQuoteCharacter();
$this->assertEquals($c . "test" . $c, $this->_platform->quoteSingleIdentifier("test"));
$this->assertEquals($c . "test.test" . $c, $this->_platform->quoteSingleIdentifier("test.test"));
$this->assertEquals(str_repeat($c, 4), $this->_platform->quoteSingleIdentifier($c));
}
示例3: validatePlatform
/**
* @param AbstractPlatform $platform
*
* @throws UnsupportedPlatformException
*/
protected function validatePlatform(AbstractPlatform $platform)
{
$platformName = $platform->getName();
if (isset($this->platforms) && !in_array($platformName, $this->platforms)) {
throw UnsupportedPlatformException::unsupportedPlatform($platformName);
}
}
示例4: getSQLDeclaration
public function getSQLDeclaration(array $fieldDeclaration, AbstractPlatform $platform)
{
if ($platform->getName() === 'mysql') {
return $platform->getVarcharTypeDeclarationSQL($fieldDeclaration) . " " . $platform->getCollationFieldDeclaration('utf8_bin');
}
return $platform->getVarcharTypeDeclarationSQL($fieldDeclaration);
}
示例5: convertToDatabaseValueSQL
/**
* @param string $sqlExpr
* @param \Doctrine\DBAL\Platforms\AbstractPlatform $platform
* @throws \Kdyby\Doctrine\NotImplementedException
* @return string
*/
public function convertToDatabaseValueSQL($sqlExpr, AbstractPlatform $platform)
{
if (!$platform instanceof Doctrine\DBAL\Platforms\MySqlPlatform) {
throw new Kdyby\Doctrine\NotImplementedException("Unsupported platform " . $platform->getName());
}
return 'GeomFromText(' . $sqlExpr . ')';
}
示例6: getSQLDeclaration
/**
* {@inheritdoc}
*/
public function getSQLDeclaration(array $fieldDeclaration, AbstractPlatform $platform)
{
if ($platform->getName() === 'postgresql') {
return 'GEOMETRY';
}
return strtoupper($this->getName());
}
示例7: getSQLDeclaration
/** {@inheritdoc} */
public function getSQLDeclaration(array $fieldDeclaration, AbstractPlatform $platform)
{
switch ($platform->getName()) {
case 'mysql':
return 'TINYINT' . (isset($fieldDeclaration['unsigned']) && $fieldDeclaration['unsigned'] ? ' UNSIGNED' : '');
default:
return $platform->getSmallIntTypeDeclarationSQL($fieldDeclaration);
}
}
示例8: walkSelectStatement
/**
* Walks down a SelectStatement AST node, wrapping it in a COUNT (SELECT DISTINCT).
*
* Note that the ORDER BY clause is not removed. Many SQL implementations (e.g. MySQL)
* are able to cache subqueries. By keeping the ORDER BY clause intact, the limitSubQuery
* that will most likely be executed next can be read from the native SQL cache.
*
* @param SelectStatement $AST
*
* @return string
*
* @throws \RuntimeException
*/
public function walkSelectStatement(SelectStatement $AST)
{
if ($this->platform->getName() === "mssql") {
$AST->orderByClause = null;
}
$sql = parent::walkSelectStatement($AST);
// Find out the SQL alias of the identifier column of the root entity
// It may be possible to make this work with multiple root entities but that
// would probably require issuing multiple queries or doing a UNION SELECT
// so for now, It's not supported.
// Get the root entity and alias from the AST fromClause
$from = $AST->fromClause->identificationVariableDeclarations;
if (count($from) > 1) {
throw new \RuntimeException("Cannot count query which selects two FROM components, cannot make distinction");
}
$fromRoot = reset($from);
$rootAlias = $fromRoot->rangeVariableDeclaration->aliasIdentificationVariable;
$rootClass = $this->queryComponents[$rootAlias]['metadata'];
$rootIdentifier = $rootClass->identifier;
// For every identifier, find out the SQL alias by combing through the ResultSetMapping
$sqlIdentifier = [];
foreach ($rootIdentifier as $property) {
if (isset($rootClass->fieldMappings[$property])) {
foreach (array_keys($this->rsm->fieldMappings, $property) as $alias) {
if ($this->rsm->columnOwnerMap[$alias] == $rootAlias) {
$sqlIdentifier[$property] = $alias;
}
}
}
if (isset($rootClass->associationMappings[$property])) {
$joinColumn = $rootClass->associationMappings[$property]['joinColumns'][0]['name'];
foreach (array_keys($this->rsm->metaMappings, $joinColumn) as $alias) {
if ($this->rsm->columnOwnerMap[$alias] == $rootAlias) {
$sqlIdentifier[$property] = $alias;
}
}
}
}
if (count($rootIdentifier) != count($sqlIdentifier)) {
throw new \RuntimeException(sprintf('Not all identifier properties can be found in the ResultSetMapping: %s', implode(', ', array_diff($rootIdentifier, array_keys($sqlIdentifier)))));
}
// Build the counter query
return sprintf('SELECT %s AS dctrn_count FROM (SELECT DISTINCT %s FROM (%s) dctrn_result) dctrn_table', $this->platform->getCountExpression('*'), implode(', ', $sqlIdentifier), $sql);
}
示例9: create
public function create($formatter, Platform $platform, $options = array())
{
$formatter = strtolower($formatter);
if (isset(self::$formatters[$formatter]) === false) {
throw new EngineException('Formatter does not exist at::' . $formatter);
}
$class = new self::$formatters[$formatter]($this->event, $this->writer->getWriter($platform->getName(), $formatter), $platform, $this->visitor, $options);
# register this formatter as a subscriber
$this->event->addSubscriber($class);
return $class;
}
示例10: getHandler
/**
* @param \Doctrine\DBAL\Platforms\AbstractPlatform $platform
* @return \Doctrine\Spatial\DBAL\HandlerInterface
*/
public function getHandler(AbstractPlatform $platform)
{
$name = $platform->getName();
if (isset($this->handlerMap[$name])) {
return $this->handlerMap[$name];
}
if (!isset($this->handlerClasses[$name])) {
throw new \RuntimeException('The database platform ' . $name . ' is not supported');
}
return $this->handlerMap[$name] = new $this->handlerClasses[$name]();
}
示例11: createOroSearchIndexTextTable
/**
* Create oro_search_index_text table
*
* @param Schema $schema
*/
protected function createOroSearchIndexTextTable(Schema $schema)
{
$table = $schema->createTable('oro_search_index_text');
$table->addColumn('id', 'integer', ['autoincrement' => true]);
$table->addColumn('item_id', 'integer', []);
$table->addColumn('field', 'string', ['length' => 250]);
$table->addColumn('value', 'text', []);
$table->addIndex(['item_id'], 'idx_a0243539126f525e', []);
$table->setPrimaryKey(['id']);
if ($this->platform->getName() === DatabasePlatformInterface::DATABASE_MYSQL) {
$table->addOption('engine', PdoMysql::ENGINE_MYISAM);
}
}
示例12: getSqlDeclaration
/**
* @param array $fieldDeclaration
* @param AbstractPlatform $platform
*
* @throws DBALException
*
* @return string
*/
public function getSqlDeclaration(array $fieldDeclaration, AbstractPlatform $platform)
{
if ($platform instanceof DB2Platform or $platform instanceof OraclePlatform or $platform instanceof SqlitePlatform or $platform instanceof SQLServerPlatform) {
throw new DBALException('ENUMs are not supported by ' . $platform->getName() . '.');
}
if (!empty($fieldDeclaration['values']) && is_array($fieldDeclaration['values'])) {
$values = array();
foreach ($fieldDeclaration['values'] as $value) {
$values[] = $platform->quoteStringLiteral($value);
}
return 'ENUM (' . implode(',', $values) . ')';
}
}
示例13: getSqlDeclaration
public function getSqlDeclaration(array $fieldDeclaration, AbstractPlatform $platform)
{
$values = implode(", ", array_map(function ($val) {
return "'" . $val . "'";
}, static::getValues()));
if ($platform instanceof MysqlPlatform) {
return sprintf('ENUM(%s)', $values);
} elseif ($platform instanceof SqlitePlatform) {
return sprintf('TEXT CHECK(%s IN (%s))', $fieldDeclaration['name'], $values);
} elseif ($platform instanceof PostgreSqlPlatform) {
return sprintf('VARCHAR(255) CHECK(%s IN (%s))', $fieldDeclaration['name'], $values);
} else {
throw new \Exception(sprintf("Sorry, platform %s currently not supported enums", $platform->getName()));
}
}
示例14: getOutput
/**
* Dump the statistics of executed queries
*
* @param boolean $dumpOnlySql
* @return void
*/
public function getOutput($dumpOnlySql = false)
{
$output = '';
if (!$dumpOnlySql) {
$output .= 'Platform: ' . $this->platform->getName() . PHP_EOL;
$output .= 'Executed queries: ' . count($this->queries) . ', total time: ' . $this->totalExecutionTime . ' ms' . PHP_EOL;
}
foreach ($this->queries as $index => $sql) {
if (!$dumpOnlySql) {
$output .= 'Query(' . ($index + 1) . ') - ' . $this->queryExecutionTimes[$index] . ' ms' . PHP_EOL;
}
$output .= $sql . ';' . PHP_EOL;
}
$output .= PHP_EOL;
return $output;
}
示例15: sqlXpathComparePropertyValue
/**
* @param $alias
* @param $property
* @param $value
* @param string $operator
*
* @return string
*
* @throws NotImplementedException if the storage backend is neither mysql
* nor postgres nor sqlite
*/
private function sqlXpathComparePropertyValue($alias, $property, $value, $operator)
{
$expression = null;
if ($this->platform instanceof MySqlPlatform) {
$expression = "EXTRACTVALUE({$alias}.props, 'count(//sv:property[@sv:name=\"" . $property . "\"]/sv:value[text()%s%s]) > 0')";
// mysql does not escape the backslashes for us, while postgres and sqlite do
$value = Xpath::escapeBackslashes($value);
} elseif ($this->platform instanceof PostgreSqlPlatform) {
$expression = "xpath_exists('//sv:property[@sv:name=\"" . $property . "\"]/sv:value[text()%s%s]', CAST({$alias}.props AS xml), " . $this->sqlXpathPostgreSQLNamespaces() . ") = 't'";
} elseif ($this->platform instanceof SqlitePlatform) {
$expression = "EXTRACTVALUE({$alias}.props, 'count(//sv:property[@sv:name=\"" . $property . "\"]/sv:value[text()%s%s]) > 0')";
} else {
throw new NotImplementedException("Xpath evaluations cannot be executed with '" . $this->platform->getName() . "' yet.");
}
return sprintf($expression, $this->walkOperator($operator), Xpath::escape($value));
}