本文整理汇总了PHP中Doctrine\DBAL\Platforms\AbstractPlatform::quoteSingleIdentifier方法的典型用法代码示例。如果您正苦于以下问题:PHP AbstractPlatform::quoteSingleIdentifier方法的具体用法?PHP AbstractPlatform::quoteSingleIdentifier怎么用?PHP AbstractPlatform::quoteSingleIdentifier使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Doctrine\DBAL\Platforms\AbstractPlatform
的用法示例。
在下文中一共展示了AbstractPlatform::quoteSingleIdentifier方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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));
}
示例2: getEntityHistory
public function getEntityHistory($className, $id)
{
if (!$this->metadataFactory->isAudited($className)) {
throw new NotAuditedException($className);
}
/** @var ClassMetadataInfo|ClassMetadata $class */
$class = $this->em->getClassMetadata($className);
$tableName = $this->config->getTableName($class);
if (!is_array($id)) {
$id = array($class->identifier[0] => $id);
}
$whereId = array();
foreach ($class->identifier as $idField) {
if (isset($class->fieldMappings[$idField])) {
$columnName = $class->fieldMappings[$idField]['columnName'];
} else {
if (isset($class->associationMappings[$idField])) {
$columnName = $class->associationMappings[$idField]['joinColumns'][0];
} else {
continue;
}
}
$whereId[] = "{$columnName} = ?";
}
$whereSQL = implode(' AND ', $whereId);
$columnList = array($this->config->getRevisionFieldName());
$columnMap = array();
foreach ($class->fieldNames as $columnName => $field) {
$type = Type::getType($class->fieldMappings[$field]['type']);
$columnList[] = $type->convertToPHPValueSQL($this->quoteStrategy->getColumnName($field, $class, $this->platform), $this->platform) . ' AS ' . $this->platform->quoteSingleIdentifier($field);
$columnMap[$field] = $this->platform->getSQLResultCasing($columnName);
}
foreach ($class->associationMappings as $assoc) {
if (($assoc['type'] & ClassMetadata::TO_ONE) == 0 || !$assoc['isOwningSide']) {
continue;
}
foreach ($assoc['targetToSourceKeyColumns'] as $sourceCol) {
$columnList[] = $sourceCol;
$columnMap[$sourceCol] = $this->platform->getSQLResultCasing($sourceCol);
}
}
$values = array_values($id);
$query = "SELECT " . implode(', ', $columnList) . " FROM " . $tableName . " e WHERE " . $whereSQL . " ORDER BY e.rev DESC";
$stmt = $this->em->getConnection()->executeQuery($query, $values);
$result = array();
while ($row = $stmt->fetch(Query::HYDRATE_ARRAY)) {
$rev = $row[$this->config->getRevisionFieldName()];
unset($row[$this->config->getRevisionFieldName()]);
$result[] = $this->createEntity($class->name, $columnMap, $row, $rev);
}
return $result;
}