use quote strategy in persister
This commit is contained in:
parent
2af7b3fd38
commit
7f64474f3e
@ -45,6 +45,13 @@ abstract class AbstractCollectionPersister
|
|||||||
*/
|
*/
|
||||||
protected $_uow;
|
protected $_uow;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The quote strategy.
|
||||||
|
*
|
||||||
|
* @var \Doctrine\ORM\Mapping\QuoteStrategy
|
||||||
|
*/
|
||||||
|
protected $quoteStrategy;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initializes a new instance of a class derived from AbstractCollectionPersister.
|
* Initializes a new instance of a class derived from AbstractCollectionPersister.
|
||||||
*
|
*
|
||||||
@ -52,9 +59,10 @@ abstract class AbstractCollectionPersister
|
|||||||
*/
|
*/
|
||||||
public function __construct(EntityManager $em)
|
public function __construct(EntityManager $em)
|
||||||
{
|
{
|
||||||
$this->_em = $em;
|
$this->_em = $em;
|
||||||
$this->_uow = $em->getUnitOfWork();
|
$this->_uow = $em->getUnitOfWork();
|
||||||
$this->_conn = $em->getConnection();
|
$this->_conn = $em->getConnection();
|
||||||
|
$this->quoteStrategy = $em->getQuoteStrategy();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -61,7 +61,7 @@ abstract class AbstractEntityInheritancePersister extends BasicEntityPersister
|
|||||||
protected function _getSelectColumnSQL($field, ClassMetadata $class, $alias = 'r')
|
protected function _getSelectColumnSQL($field, ClassMetadata $class, $alias = 'r')
|
||||||
{
|
{
|
||||||
$columnName = $class->columnNames[$field];
|
$columnName = $class->columnNames[$field];
|
||||||
$sql = $this->_getSQLTableAlias($class->name, $alias == 'r' ? '' : $alias) . '.' . $class->getQuotedColumnName($field, $this->_platform);
|
$sql = $this->_getSQLTableAlias($class->name, $alias == 'r' ? '' : $alias) . '.' . $this->quoteStrategy->getColumnName($field, $class);
|
||||||
$columnAlias = $this->getSQLColumnAlias($columnName);
|
$columnAlias = $this->getSQLColumnAlias($columnName);
|
||||||
$this->_rsm->addFieldResult($alias, $columnAlias, $field, $class->name);
|
$this->_rsm->addFieldResult($alias, $columnAlias, $field, $class->name);
|
||||||
|
|
||||||
|
@ -175,7 +175,7 @@ class BasicEntityPersister
|
|||||||
*
|
*
|
||||||
* @var \Doctrine\ORM\Mapping\QuoteStrategy
|
* @var \Doctrine\ORM\Mapping\QuoteStrategy
|
||||||
*/
|
*/
|
||||||
private $quoteStrategy;
|
protected $quoteStrategy;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initializes a new <tt>BasicEntityPersister</tt> that uses the given EntityManager
|
* Initializes a new <tt>BasicEntityPersister</tt> that uses the given EntityManager
|
||||||
@ -295,7 +295,7 @@ class BasicEntityPersister
|
|||||||
|
|
||||||
//FIXME: Order with composite keys might not be correct
|
//FIXME: Order with composite keys might not be correct
|
||||||
$sql = 'SELECT ' . $versionFieldColumnName
|
$sql = 'SELECT ' . $versionFieldColumnName
|
||||||
. ' FROM ' . $versionedClass->getQuotedTableName($this->_platform)
|
. ' FROM ' . $this->quoteStrategy->getTableName($versionedClass)
|
||||||
. ' WHERE ' . implode(' = ? AND ', $identifier) . ' = ?';
|
. ' WHERE ' . implode(' = ? AND ', $identifier) . ' = ?';
|
||||||
$value = $this->_conn->fetchColumn($sql, array_values((array)$id));
|
$value = $this->_conn->fetchColumn($sql, array_values((array)$id));
|
||||||
|
|
||||||
@ -469,7 +469,7 @@ class BasicEntityPersister
|
|||||||
$identifier = $this->_em->getUnitOfWork()->getEntityIdentifier($entity);
|
$identifier = $this->_em->getUnitOfWork()->getEntityIdentifier($entity);
|
||||||
$this->deleteJoinTableRecords($identifier);
|
$this->deleteJoinTableRecords($identifier);
|
||||||
|
|
||||||
$id = array_combine($this->quoteStrategy->getIdentifierColumnNames($this->_class), $identifier);
|
$id = array_combine($this->_class->getIdentifierColumnNames(), $identifier);
|
||||||
$this->_conn->delete($this->quoteStrategy->getTableName($this->_class), $id);
|
$this->_conn->delete($this->quoteStrategy->getTableName($this->_class), $id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -105,7 +105,7 @@ class JoinedSubclassPersister extends AbstractEntityInheritancePersister
|
|||||||
$tableName = $cm->getTableName();
|
$tableName = $cm->getTableName();
|
||||||
|
|
||||||
$this->_owningTableMap[$fieldName] = $tableName;
|
$this->_owningTableMap[$fieldName] = $tableName;
|
||||||
$this->_quotedTableMap[$tableName] = $cm->getQuotedTableName($this->_platform);
|
$this->_quotedTableMap[$tableName] = $this->quoteStrategy->getTableName($cm);
|
||||||
|
|
||||||
return $tableName;
|
return $tableName;
|
||||||
}
|
}
|
||||||
@ -225,7 +225,7 @@ class JoinedSubclassPersister extends AbstractEntityInheritancePersister
|
|||||||
// Make sure the table with the version column is updated even if no columns on that
|
// Make sure the table with the version column is updated even if no columns on that
|
||||||
// table were affected.
|
// table were affected.
|
||||||
if ($isVersioned && ! isset($updateData[$versionedTable])) {
|
if ($isVersioned && ! isset($updateData[$versionedTable])) {
|
||||||
$this->_updateTable($entity, $versionedClass->getQuotedTableName($this->_platform), array(), true);
|
$this->_updateTable($entity, $this->quoteStrategy->getTableName($versionedClass), array(), true);
|
||||||
|
|
||||||
$id = $this->_em->getUnitOfWork()->getEntityIdentifier($entity);
|
$id = $this->_em->getUnitOfWork()->getEntityIdentifier($entity);
|
||||||
$this->assignDefaultVersionValue($entity, $id);
|
$this->assignDefaultVersionValue($entity, $id);
|
||||||
@ -247,11 +247,11 @@ class JoinedSubclassPersister extends AbstractEntityInheritancePersister
|
|||||||
// delete the row from the root table. Cascades do the rest.
|
// delete the row from the root table. Cascades do the rest.
|
||||||
if ($this->_platform->supportsForeignKeyConstraints()) {
|
if ($this->_platform->supportsForeignKeyConstraints()) {
|
||||||
$this->_conn->delete(
|
$this->_conn->delete(
|
||||||
$this->_em->getClassMetadata($this->_class->rootEntityName)->getQuotedTableName($this->_platform), $id
|
$this->quoteStrategy->getTableName($this->_em->getClassMetadata($this->_class->rootEntityName)), $id
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
// Delete from all tables individually, starting from this class' table up to the root table.
|
// Delete from all tables individually, starting from this class' table up to the root table.
|
||||||
$this->_conn->delete($this->_class->getQuotedTableName($this->_platform), $id);
|
$this->_conn->delete($this->quoteStrategy->getTableName($this->_class), $id);
|
||||||
|
|
||||||
foreach ($this->_class->parentClasses as $parentClass) {
|
foreach ($this->_class->parentClasses as $parentClass) {
|
||||||
$this->_conn->delete(
|
$this->_conn->delete(
|
||||||
|
@ -78,11 +78,10 @@ class ManyToManyPersister extends AbstractCollectionPersister
|
|||||||
*/
|
*/
|
||||||
protected function _getInsertRowSQL(PersistentCollection $coll)
|
protected function _getInsertRowSQL(PersistentCollection $coll)
|
||||||
{
|
{
|
||||||
$mapping = $coll->getMapping();
|
$mapping = $coll->getMapping();
|
||||||
$columns = $mapping['joinTableColumns'];
|
$columns = $mapping['joinTableColumns'];
|
||||||
$class = $this->_em->getClassMetadata(get_class($coll->getOwner()));
|
$class = $this->_em->getClassMetadata(get_class($coll->getOwner()));
|
||||||
|
$joinTable = $this->quoteStrategy->getJoinTableName($mapping, $class);
|
||||||
$joinTable = $class->getQuotedJoinTableName($mapping, $this->_conn->getDatabasePlatform());
|
|
||||||
|
|
||||||
return 'INSERT INTO ' . $joinTable . ' (' . implode(', ', $columns) . ')'
|
return 'INSERT INTO ' . $joinTable . ' (' . implode(', ', $columns) . ')'
|
||||||
. ' VALUES (' . implode(', ', array_fill(0, count($columns), '?')) . ')';
|
. ' VALUES (' . implode(', ', array_fill(0, count($columns), '?')) . ')';
|
||||||
@ -150,10 +149,11 @@ class ManyToManyPersister extends AbstractCollectionPersister
|
|||||||
*/
|
*/
|
||||||
protected function _getDeleteSQL(PersistentCollection $coll)
|
protected function _getDeleteSQL(PersistentCollection $coll)
|
||||||
{
|
{
|
||||||
$class = $this->_em->getClassMetadata(get_class($coll->getOwner()));
|
$class = $this->_em->getClassMetadata(get_class($coll->getOwner()));
|
||||||
$mapping = $coll->getMapping();
|
$mapping = $coll->getMapping();
|
||||||
|
$joinTable = $this->quoteStrategy->getJoinTableName($mapping, $class);
|
||||||
|
|
||||||
return 'DELETE FROM ' . $class->getQuotedJoinTableName($mapping, $this->_conn->getDatabasePlatform())
|
return 'DELETE FROM ' . $joinTable
|
||||||
. ' WHERE ' . implode(' = ? AND ', array_keys($mapping['relationToSourceKeyColumns'])) . ' = ?';
|
. ' WHERE ' . implode(' = ? AND ', array_keys($mapping['relationToSourceKeyColumns'])) . ' = ?';
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -224,7 +224,7 @@ class ManyToManyPersister extends AbstractCollectionPersister
|
|||||||
}
|
}
|
||||||
|
|
||||||
$sql = 'SELECT COUNT(*)'
|
$sql = 'SELECT COUNT(*)'
|
||||||
. ' FROM ' . $class->getQuotedJoinTableName($mapping, $this->_conn->getDatabasePlatform()) . ' t'
|
. ' FROM ' . $this->quoteStrategy->getJoinTableName($mapping, $class) . ' t'
|
||||||
. $joinTargetEntitySQL
|
. $joinTargetEntitySQL
|
||||||
. ' WHERE ' . implode(' AND ', $whereClauses);
|
. ' WHERE ' . implode(' AND ', $whereClauses);
|
||||||
|
|
||||||
@ -326,7 +326,7 @@ class ManyToManyPersister extends AbstractCollectionPersister
|
|||||||
$targetId = $uow->getEntityIdentifier($element);
|
$targetId = $uow->getEntityIdentifier($element);
|
||||||
}
|
}
|
||||||
|
|
||||||
$quotedJoinTable = $sourceClass->getQuotedJoinTableName($mapping, $this->_conn->getDatabasePlatform());
|
$quotedJoinTable = $this->quoteStrategy->getJoinTableName($mapping, $sourceClass);
|
||||||
$whereClauses = array();
|
$whereClauses = array();
|
||||||
$params = array();
|
$params = array();
|
||||||
|
|
||||||
@ -387,7 +387,7 @@ class ManyToManyPersister extends AbstractCollectionPersister
|
|||||||
$joinTargetEntitySQL = '';
|
$joinTargetEntitySQL = '';
|
||||||
if ($filterSql = $this->generateFilterConditionSQL($targetClass, 'te')) {
|
if ($filterSql = $this->generateFilterConditionSQL($targetClass, 'te')) {
|
||||||
$joinTargetEntitySQL = ' JOIN '
|
$joinTargetEntitySQL = ' JOIN '
|
||||||
. $targetClass->getQuotedTableName($this->_conn->getDatabasePlatform()) . ' te'
|
. $this->quoteStrategy->getTableName($targetClass) . ' te'
|
||||||
. ' ON';
|
. ' ON';
|
||||||
|
|
||||||
$joinTargetEntitySQLClauses = array();
|
$joinTargetEntitySQLClauses = array();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user