remove '_' prefix at BasicEntityPersister
This commit is contained in:
parent
262c3eea6b
commit
b998a522b0
@ -36,14 +36,14 @@ abstract class AbstractEntityInheritancePersister extends BasicEntityPersister
|
|||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
protected function _prepareInsertData($entity)
|
protected function prepareInsertData($entity)
|
||||||
{
|
{
|
||||||
$data = parent::_prepareInsertData($entity);
|
$data = parent::prepareInsertData($entity);
|
||||||
|
|
||||||
// Populate the discriminator column
|
// Populate the discriminator column
|
||||||
$discColumn = $this->_class->discriminatorColumn;
|
$discColumn = $this->class->discriminatorColumn;
|
||||||
$this->_columnTypes[$discColumn['name']] = $discColumn['type'];
|
$this->columnTypes[$discColumn['name']] = $discColumn['type'];
|
||||||
$data[$this->_getDiscriminatorColumnTableName()][$discColumn['name']] = $this->_class->discriminatorValue;
|
$data[$this->getDiscriminatorColumnTableName()][$discColumn['name']] = $this->class->discriminatorValue;
|
||||||
|
|
||||||
return $data;
|
return $data;
|
||||||
}
|
}
|
||||||
@ -53,21 +53,21 @@ abstract class AbstractEntityInheritancePersister extends BasicEntityPersister
|
|||||||
*
|
*
|
||||||
* @return string The table name.
|
* @return string The table name.
|
||||||
*/
|
*/
|
||||||
abstract protected function _getDiscriminatorColumnTableName();
|
abstract protected function getDiscriminatorColumnTableName();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
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) . '.' . $this->quoteStrategy->getColumnName($field, $class, $this->_platform);
|
$sql = $this->getSQLTableAlias($class->name, $alias == 'r' ? '' : $alias) . '.' . $this->quoteStrategy->getColumnName($field, $class, $this->platform);
|
||||||
$columnAlias = $this->getSQLColumnAlias($columnName);
|
$columnAlias = $this->getSQLColumnAlias($columnName);
|
||||||
$this->_rsm->addFieldResult($alias, $columnAlias, $field, $class->name);
|
$this->rsm->addFieldResult($alias, $columnAlias, $field, $class->name);
|
||||||
|
|
||||||
if (isset($class->fieldMappings[$field]['requireSQLConversion'])) {
|
if (isset($class->fieldMappings[$field]['requireSQLConversion'])) {
|
||||||
$type = Type::getType($class->getTypeOfField($field));
|
$type = Type::getType($class->getTypeOfField($field));
|
||||||
$sql = $type->convertToPHPValueSQL($sql, $this->_platform);
|
$sql = $type->convertToPHPValueSQL($sql, $this->platform);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $sql . ' AS ' . $columnAlias;
|
return $sql . ' AS ' . $columnAlias;
|
||||||
@ -76,7 +76,7 @@ abstract class AbstractEntityInheritancePersister extends BasicEntityPersister
|
|||||||
protected function getSelectJoinColumnSQL($tableAlias, $joinColumnName, $className)
|
protected function getSelectJoinColumnSQL($tableAlias, $joinColumnName, $className)
|
||||||
{
|
{
|
||||||
$columnAlias = $this->getSQLColumnAlias($joinColumnName);
|
$columnAlias = $this->getSQLColumnAlias($joinColumnName);
|
||||||
$this->_rsm->addMetaResult('r', $columnAlias, $joinColumnName);
|
$this->rsm->addMetaResult('r', $columnAlias, $joinColumnName);
|
||||||
|
|
||||||
return $tableAlias . '.' . $joinColumnName . ' AS ' . $columnAlias;
|
return $tableAlias . '.' . $joinColumnName . ' AS ' . $columnAlias;
|
||||||
}
|
}
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -45,23 +45,23 @@ class JoinedSubclassPersister extends AbstractEntityInheritancePersister
|
|||||||
*
|
*
|
||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
private $_owningTableMap = array();
|
private $owningTableMap = array();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Map of table to quoted table names.
|
* Map of table to quoted table names.
|
||||||
*
|
*
|
||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
private $_quotedTableMap = array();
|
private $quotedTableMap = array();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
protected function _getDiscriminatorColumnTableName()
|
protected function getDiscriminatorColumnTableName()
|
||||||
{
|
{
|
||||||
$class = ($this->_class->name !== $this->_class->rootEntityName)
|
$class = ($this->class->name !== $this->class->rootEntityName)
|
||||||
? $this->_em->getClassMetadata($this->_class->rootEntityName)
|
? $this->em->getClassMetadata($this->class->rootEntityName)
|
||||||
: $this->_class;
|
: $this->class;
|
||||||
|
|
||||||
return $class->getTableName();
|
return $class->getTableName();
|
||||||
}
|
}
|
||||||
@ -72,15 +72,15 @@ class JoinedSubclassPersister extends AbstractEntityInheritancePersister
|
|||||||
*
|
*
|
||||||
* @return \Doctrine\ORM\Mapping\ClassMetadata
|
* @return \Doctrine\ORM\Mapping\ClassMetadata
|
||||||
*/
|
*/
|
||||||
private function _getVersionedClassMetadata()
|
private function getVersionedClassMetadata()
|
||||||
{
|
{
|
||||||
if (isset($this->_class->fieldMappings[$this->_class->versionField]['inherited'])) {
|
if (isset($this->class->fieldMappings[$this->class->versionField]['inherited'])) {
|
||||||
$definingClassName = $this->_class->fieldMappings[$this->_class->versionField]['inherited'];
|
$definingClassName = $this->class->fieldMappings[$this->class->versionField]['inherited'];
|
||||||
|
|
||||||
return $this->_em->getClassMetadata($definingClassName);
|
return $this->em->getClassMetadata($definingClassName);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->_class;
|
return $this->class;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -92,22 +92,22 @@ class JoinedSubclassPersister extends AbstractEntityInheritancePersister
|
|||||||
*/
|
*/
|
||||||
public function getOwningTable($fieldName)
|
public function getOwningTable($fieldName)
|
||||||
{
|
{
|
||||||
if (isset($this->_owningTableMap[$fieldName])) {
|
if (isset($this->owningTableMap[$fieldName])) {
|
||||||
return $this->_owningTableMap[$fieldName];
|
return $this->owningTableMap[$fieldName];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isset($this->_class->associationMappings[$fieldName]['inherited'])) {
|
if (isset($this->class->associationMappings[$fieldName]['inherited'])) {
|
||||||
$cm = $this->_em->getClassMetadata($this->_class->associationMappings[$fieldName]['inherited']);
|
$cm = $this->em->getClassMetadata($this->class->associationMappings[$fieldName]['inherited']);
|
||||||
} else if (isset($this->_class->fieldMappings[$fieldName]['inherited'])) {
|
} else if (isset($this->class->fieldMappings[$fieldName]['inherited'])) {
|
||||||
$cm = $this->_em->getClassMetadata($this->_class->fieldMappings[$fieldName]['inherited']);
|
$cm = $this->em->getClassMetadata($this->class->fieldMappings[$fieldName]['inherited']);
|
||||||
} else {
|
} else {
|
||||||
$cm = $this->_class;
|
$cm = $this->class;
|
||||||
}
|
}
|
||||||
|
|
||||||
$tableName = $cm->getTableName();
|
$tableName = $cm->getTableName();
|
||||||
|
|
||||||
$this->_owningTableMap[$fieldName] = $tableName;
|
$this->owningTableMap[$fieldName] = $tableName;
|
||||||
$this->_quotedTableMap[$tableName] = $this->quoteStrategy->getTableName($cm, $this->_platform);
|
$this->quotedTableMap[$tableName] = $this->quoteStrategy->getTableName($cm, $this->platform);
|
||||||
|
|
||||||
return $tableName;
|
return $tableName;
|
||||||
}
|
}
|
||||||
@ -117,57 +117,57 @@ class JoinedSubclassPersister extends AbstractEntityInheritancePersister
|
|||||||
*/
|
*/
|
||||||
public function executeInserts()
|
public function executeInserts()
|
||||||
{
|
{
|
||||||
if ( ! $this->_queuedInserts) {
|
if ( ! $this->queuedInserts) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$postInsertIds = array();
|
$postInsertIds = array();
|
||||||
$idGen = $this->_class->idGenerator;
|
$idGen = $this->class->idGenerator;
|
||||||
$isPostInsertId = $idGen->isPostInsertGenerator();
|
$isPostInsertId = $idGen->isPostInsertGenerator();
|
||||||
|
|
||||||
// Prepare statement for the root table
|
// Prepare statement for the root table
|
||||||
$rootClass = ($this->_class->name !== $this->_class->rootEntityName) ? $this->_em->getClassMetadata($this->_class->rootEntityName) : $this->_class;
|
$rootClass = ($this->class->name !== $this->class->rootEntityName) ? $this->em->getClassMetadata($this->class->rootEntityName) : $this->class;
|
||||||
$rootPersister = $this->_em->getUnitOfWork()->getEntityPersister($rootClass->name);
|
$rootPersister = $this->em->getUnitOfWork()->getEntityPersister($rootClass->name);
|
||||||
$rootTableName = $rootClass->getTableName();
|
$rootTableName = $rootClass->getTableName();
|
||||||
$rootTableStmt = $this->_conn->prepare($rootPersister->_getInsertSQL());
|
$rootTableStmt = $this->conn->prepare($rootPersister->getInsertSQL());
|
||||||
|
|
||||||
// Prepare statements for sub tables.
|
// Prepare statements for sub tables.
|
||||||
$subTableStmts = array();
|
$subTableStmts = array();
|
||||||
|
|
||||||
if ($rootClass !== $this->_class) {
|
if ($rootClass !== $this->class) {
|
||||||
$subTableStmts[$this->_class->getTableName()] = $this->_conn->prepare($this->_getInsertSQL());
|
$subTableStmts[$this->class->getTableName()] = $this->conn->prepare($this->getInsertSQL());
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach ($this->_class->parentClasses as $parentClassName) {
|
foreach ($this->class->parentClasses as $parentClassName) {
|
||||||
$parentClass = $this->_em->getClassMetadata($parentClassName);
|
$parentClass = $this->em->getClassMetadata($parentClassName);
|
||||||
$parentTableName = $parentClass->getTableName();
|
$parentTableName = $parentClass->getTableName();
|
||||||
|
|
||||||
if ($parentClass !== $rootClass) {
|
if ($parentClass !== $rootClass) {
|
||||||
$parentPersister = $this->_em->getUnitOfWork()->getEntityPersister($parentClassName);
|
$parentPersister = $this->em->getUnitOfWork()->getEntityPersister($parentClassName);
|
||||||
$subTableStmts[$parentTableName] = $this->_conn->prepare($parentPersister->_getInsertSQL());
|
$subTableStmts[$parentTableName] = $this->conn->prepare($parentPersister->getInsertSQL());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Execute all inserts. For each entity:
|
// Execute all inserts. For each entity:
|
||||||
// 1) Insert on root table
|
// 1) Insert on root table
|
||||||
// 2) Insert on sub tables
|
// 2) Insert on sub tables
|
||||||
foreach ($this->_queuedInserts as $entity) {
|
foreach ($this->queuedInserts as $entity) {
|
||||||
$insertData = $this->_prepareInsertData($entity);
|
$insertData = $this->prepareInsertData($entity);
|
||||||
|
|
||||||
// Execute insert on root table
|
// Execute insert on root table
|
||||||
$paramIndex = 1;
|
$paramIndex = 1;
|
||||||
|
|
||||||
foreach ($insertData[$rootTableName] as $columnName => $value) {
|
foreach ($insertData[$rootTableName] as $columnName => $value) {
|
||||||
$rootTableStmt->bindValue($paramIndex++, $value, $this->_columnTypes[$columnName]);
|
$rootTableStmt->bindValue($paramIndex++, $value, $this->columnTypes[$columnName]);
|
||||||
}
|
}
|
||||||
|
|
||||||
$rootTableStmt->execute();
|
$rootTableStmt->execute();
|
||||||
|
|
||||||
if ($isPostInsertId) {
|
if ($isPostInsertId) {
|
||||||
$id = $idGen->generate($this->_em, $entity);
|
$id = $idGen->generate($this->em, $entity);
|
||||||
$postInsertIds[$id] = $entity;
|
$postInsertIds[$id] = $entity;
|
||||||
} else {
|
} else {
|
||||||
$id = $this->_em->getUnitOfWork()->getEntityIdentifier($entity);
|
$id = $this->em->getUnitOfWork()->getEntityIdentifier($entity);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Execute inserts on subtables.
|
// Execute inserts on subtables.
|
||||||
@ -177,13 +177,13 @@ class JoinedSubclassPersister extends AbstractEntityInheritancePersister
|
|||||||
$paramIndex = 1;
|
$paramIndex = 1;
|
||||||
|
|
||||||
foreach ((array) $id as $idName => $idVal) {
|
foreach ((array) $id as $idName => $idVal) {
|
||||||
$type = isset($this->_columnTypes[$idName]) ? $this->_columnTypes[$idName] : Type::STRING;
|
$type = isset($this->columnTypes[$idName]) ? $this->columnTypes[$idName] : Type::STRING;
|
||||||
|
|
||||||
$stmt->bindValue($paramIndex++, $idVal, $type);
|
$stmt->bindValue($paramIndex++, $idVal, $type);
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach ($data as $columnName => $value) {
|
foreach ($data as $columnName => $value) {
|
||||||
$stmt->bindValue($paramIndex++, $value, $this->_columnTypes[$columnName]);
|
$stmt->bindValue($paramIndex++, $value, $this->columnTypes[$columnName]);
|
||||||
}
|
}
|
||||||
|
|
||||||
$stmt->execute();
|
$stmt->execute();
|
||||||
@ -196,11 +196,11 @@ class JoinedSubclassPersister extends AbstractEntityInheritancePersister
|
|||||||
$stmt->closeCursor();
|
$stmt->closeCursor();
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($this->_class->isVersioned) {
|
if ($this->class->isVersioned) {
|
||||||
$this->assignDefaultVersionValue($entity, $id);
|
$this->assignDefaultVersionValue($entity, $id);
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->_queuedInserts = array();
|
$this->queuedInserts = array();
|
||||||
|
|
||||||
return $postInsertIds;
|
return $postInsertIds;
|
||||||
}
|
}
|
||||||
@ -210,26 +210,26 @@ class JoinedSubclassPersister extends AbstractEntityInheritancePersister
|
|||||||
*/
|
*/
|
||||||
public function update($entity)
|
public function update($entity)
|
||||||
{
|
{
|
||||||
$updateData = $this->_prepareUpdateData($entity);
|
$updateData = $this->prepareUpdateData($entity);
|
||||||
|
|
||||||
if (($isVersioned = $this->_class->isVersioned) != false) {
|
if (($isVersioned = $this->class->isVersioned) != false) {
|
||||||
$versionedClass = $this->_getVersionedClassMetadata();
|
$versionedClass = $this->getVersionedClassMetadata();
|
||||||
$versionedTable = $versionedClass->getTableName();
|
$versionedTable = $versionedClass->getTableName();
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($updateData) {
|
if ($updateData) {
|
||||||
foreach ($updateData as $tableName => $data) {
|
foreach ($updateData as $tableName => $data) {
|
||||||
$this->_updateTable(
|
$this->updateTable(
|
||||||
$entity, $this->_quotedTableMap[$tableName], $data, $isVersioned && $versionedTable == $tableName
|
$entity, $this->quotedTableMap[$tableName], $data, $isVersioned && $versionedTable == $tableName
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 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, $this->quoteStrategy->getTableName($versionedClass, $this->_platform), array(), true);
|
$this->updateTable($entity, $this->quoteStrategy->getTableName($versionedClass, $this->platform), array(), true);
|
||||||
|
|
||||||
$id = $this->_em->getUnitOfWork()->getEntityIdentifier($entity);
|
$id = $this->em->getUnitOfWork()->getEntityIdentifier($entity);
|
||||||
$this->assignDefaultVersionValue($entity, $id);
|
$this->assignDefaultVersionValue($entity, $id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -240,24 +240,24 @@ class JoinedSubclassPersister extends AbstractEntityInheritancePersister
|
|||||||
*/
|
*/
|
||||||
public function delete($entity)
|
public function delete($entity)
|
||||||
{
|
{
|
||||||
$identifier = $this->_em->getUnitOfWork()->getEntityIdentifier($entity);
|
$identifier = $this->em->getUnitOfWork()->getEntityIdentifier($entity);
|
||||||
$this->deleteJoinTableRecords($identifier);
|
$this->deleteJoinTableRecords($identifier);
|
||||||
|
|
||||||
$id = array_combine($this->_class->getIdentifierColumnNames(), $identifier);
|
$id = array_combine($this->class->getIdentifierColumnNames(), $identifier);
|
||||||
|
|
||||||
// If the database platform supports FKs, just
|
// If the database platform supports FKs, just
|
||||||
// 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->quoteStrategy->getTableName($this->_em->getClassMetadata($this->_class->rootEntityName), $this->_platform), $id
|
$this->quoteStrategy->getTableName($this->em->getClassMetadata($this->class->rootEntityName), $this->platform), $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->quoteStrategy->getTableName($this->_class, $this->_platform), $id);
|
$this->conn->delete($this->quoteStrategy->getTableName($this->class, $this->platform), $id);
|
||||||
|
|
||||||
foreach ($this->_class->parentClasses as $parentClass) {
|
foreach ($this->class->parentClasses as $parentClass) {
|
||||||
$this->_conn->delete(
|
$this->conn->delete(
|
||||||
$this->quoteStrategy->getTableName($this->_em->getClassMetadata($parentClass), $this->_platform), $id
|
$this->quoteStrategy->getTableName($this->em->getClassMetadata($parentClass), $this->platform), $id
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -266,33 +266,33 @@ class JoinedSubclassPersister extends AbstractEntityInheritancePersister
|
|||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
protected function _getSelectEntitiesSQL($criteria, $assoc = null, $lockMode = 0, $limit = null, $offset = null, array $orderBy = null)
|
protected function getSelectEntitiesSQL($criteria, $assoc = null, $lockMode = 0, $limit = null, $offset = null, array $orderBy = null)
|
||||||
{
|
{
|
||||||
$idColumns = $this->_class->getIdentifierColumnNames();
|
$idColumns = $this->class->getIdentifierColumnNames();
|
||||||
$baseTableAlias = $this->_getSQLTableAlias($this->_class->name);
|
$baseTableAlias = $this->getSQLTableAlias($this->class->name);
|
||||||
|
|
||||||
// Create the column list fragment only once
|
// Create the column list fragment only once
|
||||||
if ($this->_selectColumnListSql === null) {
|
if ($this->selectColumnListSql === null) {
|
||||||
|
|
||||||
$this->_rsm = new ResultSetMapping();
|
$this->rsm = new ResultSetMapping();
|
||||||
$this->_rsm->addEntityResult($this->_class->name, 'r');
|
$this->rsm->addEntityResult($this->class->name, 'r');
|
||||||
|
|
||||||
// Add regular columns
|
// Add regular columns
|
||||||
$columnList = '';
|
$columnList = '';
|
||||||
|
|
||||||
foreach ($this->_class->fieldMappings as $fieldName => $mapping) {
|
foreach ($this->class->fieldMappings as $fieldName => $mapping) {
|
||||||
if ($columnList != '') $columnList .= ', ';
|
if ($columnList != '') $columnList .= ', ';
|
||||||
|
|
||||||
$columnList .= $this->_getSelectColumnSQL(
|
$columnList .= $this->getSelectColumnSQL(
|
||||||
$fieldName,
|
$fieldName,
|
||||||
isset($mapping['inherited']) ? $this->_em->getClassMetadata($mapping['inherited']) : $this->_class
|
isset($mapping['inherited']) ? $this->em->getClassMetadata($mapping['inherited']) : $this->class
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add foreign key columns
|
// Add foreign key columns
|
||||||
foreach ($this->_class->associationMappings as $assoc2) {
|
foreach ($this->class->associationMappings as $assoc2) {
|
||||||
if ($assoc2['isOwningSide'] && $assoc2['type'] & ClassMetadata::TO_ONE) {
|
if ($assoc2['isOwningSide'] && $assoc2['type'] & ClassMetadata::TO_ONE) {
|
||||||
$tableAlias = isset($assoc2['inherited']) ? $this->_getSQLTableAlias($assoc2['inherited']) : $baseTableAlias;
|
$tableAlias = isset($assoc2['inherited']) ? $this->getSQLTableAlias($assoc2['inherited']) : $baseTableAlias;
|
||||||
|
|
||||||
foreach ($assoc2['targetToSourceKeyColumns'] as $srcColumn) {
|
foreach ($assoc2['targetToSourceKeyColumns'] as $srcColumn) {
|
||||||
if ($columnList != '') $columnList .= ', ';
|
if ($columnList != '') $columnList .= ', ';
|
||||||
@ -300,30 +300,30 @@ class JoinedSubclassPersister extends AbstractEntityInheritancePersister
|
|||||||
$columnList .= $this->getSelectJoinColumnSQL(
|
$columnList .= $this->getSelectJoinColumnSQL(
|
||||||
$tableAlias,
|
$tableAlias,
|
||||||
$srcColumn,
|
$srcColumn,
|
||||||
isset($assoc2['inherited']) ? $assoc2['inherited'] : $this->_class->name
|
isset($assoc2['inherited']) ? $assoc2['inherited'] : $this->class->name
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add discriminator column (DO NOT ALIAS, see AbstractEntityInheritancePersister#_processSQLResult).
|
// Add discriminator column (DO NOT ALIAS, see AbstractEntityInheritancePersister#_processSQLResult).
|
||||||
$discrColumn = $this->_class->discriminatorColumn['name'];
|
$discrColumn = $this->class->discriminatorColumn['name'];
|
||||||
$tableAlias = ($this->_class->rootEntityName == $this->_class->name) ? $baseTableAlias : $this->_getSQLTableAlias($this->_class->rootEntityName);
|
$tableAlias = ($this->class->rootEntityName == $this->class->name) ? $baseTableAlias : $this->getSQLTableAlias($this->class->rootEntityName);
|
||||||
$columnList .= ', ' . $tableAlias . '.' . $discrColumn;
|
$columnList .= ', ' . $tableAlias . '.' . $discrColumn;
|
||||||
|
|
||||||
$resultColumnName = $this->_platform->getSQLResultCasing($discrColumn);
|
$resultColumnName = $this->platform->getSQLResultCasing($discrColumn);
|
||||||
|
|
||||||
$this->_rsm->setDiscriminatorColumn('r', $resultColumnName);
|
$this->rsm->setDiscriminatorColumn('r', $resultColumnName);
|
||||||
$this->_rsm->addMetaResult('r', $resultColumnName, $discrColumn);
|
$this->rsm->addMetaResult('r', $resultColumnName, $discrColumn);
|
||||||
}
|
}
|
||||||
|
|
||||||
// INNER JOIN parent tables
|
// INNER JOIN parent tables
|
||||||
$joinSql = '';
|
$joinSql = '';
|
||||||
|
|
||||||
foreach ($this->_class->parentClasses as $parentClassName) {
|
foreach ($this->class->parentClasses as $parentClassName) {
|
||||||
$parentClass = $this->_em->getClassMetadata($parentClassName);
|
$parentClass = $this->em->getClassMetadata($parentClassName);
|
||||||
$tableAlias = $this->_getSQLTableAlias($parentClassName);
|
$tableAlias = $this->getSQLTableAlias($parentClassName);
|
||||||
$joinSql .= ' INNER JOIN ' . $this->quoteStrategy->getTableName($parentClass, $this->_platform) . ' ' . $tableAlias . ' ON ';
|
$joinSql .= ' INNER JOIN ' . $this->quoteStrategy->getTableName($parentClass, $this->platform) . ' ' . $tableAlias . ' ON ';
|
||||||
$first = true;
|
$first = true;
|
||||||
|
|
||||||
foreach ($idColumns as $idColumn) {
|
foreach ($idColumns as $idColumn) {
|
||||||
@ -334,16 +334,16 @@ class JoinedSubclassPersister extends AbstractEntityInheritancePersister
|
|||||||
}
|
}
|
||||||
|
|
||||||
// OUTER JOIN sub tables
|
// OUTER JOIN sub tables
|
||||||
foreach ($this->_class->subClasses as $subClassName) {
|
foreach ($this->class->subClasses as $subClassName) {
|
||||||
$subClass = $this->_em->getClassMetadata($subClassName);
|
$subClass = $this->em->getClassMetadata($subClassName);
|
||||||
$tableAlias = $this->_getSQLTableAlias($subClassName);
|
$tableAlias = $this->getSQLTableAlias($subClassName);
|
||||||
|
|
||||||
if ($this->_selectColumnListSql === null) {
|
if ($this->selectColumnListSql === null) {
|
||||||
// Add subclass columns
|
// Add subclass columns
|
||||||
foreach ($subClass->fieldMappings as $fieldName => $mapping) {
|
foreach ($subClass->fieldMappings as $fieldName => $mapping) {
|
||||||
if (isset($mapping['inherited'])) continue;
|
if (isset($mapping['inherited'])) continue;
|
||||||
|
|
||||||
$columnList .= ', ' . $this->_getSelectColumnSQL($fieldName, $subClass);
|
$columnList .= ', ' . $this->getSelectColumnSQL($fieldName, $subClass);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add join columns (foreign keys)
|
// Add join columns (foreign keys)
|
||||||
@ -363,7 +363,7 @@ class JoinedSubclassPersister extends AbstractEntityInheritancePersister
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Add LEFT JOIN
|
// Add LEFT JOIN
|
||||||
$joinSql .= ' LEFT JOIN ' . $this->quoteStrategy->getTableName($subClass, $this->_platform) . ' ' . $tableAlias . ' ON ';
|
$joinSql .= ' LEFT JOIN ' . $this->quoteStrategy->getTableName($subClass, $this->platform) . ' ' . $tableAlias . ' ON ';
|
||||||
$first = true;
|
$first = true;
|
||||||
|
|
||||||
foreach ($idColumns as $idColumn) {
|
foreach ($idColumns as $idColumn) {
|
||||||
@ -373,14 +373,14 @@ class JoinedSubclassPersister extends AbstractEntityInheritancePersister
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$joinSql .= ($assoc != null && $assoc['type'] == ClassMetadata::MANY_TO_MANY) ? $this->_getSelectManyToManyJoinSQL($assoc) : '';
|
$joinSql .= ($assoc != null && $assoc['type'] == ClassMetadata::MANY_TO_MANY) ? $this->getSelectManyToManyJoinSQL($assoc) : '';
|
||||||
|
|
||||||
$conditionSql = ($criteria instanceof Criteria)
|
$conditionSql = ($criteria instanceof Criteria)
|
||||||
? $this->_getSelectConditionCriteriaSQL($criteria)
|
? $this->getSelectConditionCriteriaSQL($criteria)
|
||||||
: $this->_getSelectConditionSQL($criteria, $assoc);
|
: $this->getSelectConditionSQL($criteria, $assoc);
|
||||||
|
|
||||||
// If the current class in the root entity, add the filters
|
// If the current class in the root entity, add the filters
|
||||||
if ($filterSql = $this->generateFilterConditionSQL($this->_em->getClassMetadata($this->_class->rootEntityName), $this->_getSQLTableAlias($this->_class->rootEntityName))) {
|
if ($filterSql = $this->generateFilterConditionSQL($this->em->getClassMetadata($this->class->rootEntityName), $this->getSQLTableAlias($this->class->rootEntityName))) {
|
||||||
if ($conditionSql) {
|
if ($conditionSql) {
|
||||||
$conditionSql .= ' AND ';
|
$conditionSql .= ' AND ';
|
||||||
}
|
}
|
||||||
@ -389,22 +389,22 @@ class JoinedSubclassPersister extends AbstractEntityInheritancePersister
|
|||||||
}
|
}
|
||||||
|
|
||||||
$orderBy = ($assoc !== null && isset($assoc['orderBy'])) ? $assoc['orderBy'] : $orderBy;
|
$orderBy = ($assoc !== null && isset($assoc['orderBy'])) ? $assoc['orderBy'] : $orderBy;
|
||||||
$orderBySql = $orderBy ? $this->_getOrderBySQL($orderBy, $baseTableAlias) : '';
|
$orderBySql = $orderBy ? $this->getOrderBySQL($orderBy, $baseTableAlias) : '';
|
||||||
|
|
||||||
if ($this->_selectColumnListSql === null) {
|
if ($this->selectColumnListSql === null) {
|
||||||
$this->_selectColumnListSql = $columnList;
|
$this->selectColumnListSql = $columnList;
|
||||||
}
|
}
|
||||||
|
|
||||||
$lockSql = '';
|
$lockSql = '';
|
||||||
|
|
||||||
if ($lockMode == LockMode::PESSIMISTIC_READ) {
|
if ($lockMode == LockMode::PESSIMISTIC_READ) {
|
||||||
$lockSql = ' ' . $this->_platform->getReadLockSql();
|
$lockSql = ' ' . $this->platform->getReadLockSql();
|
||||||
} else if ($lockMode == LockMode::PESSIMISTIC_WRITE) {
|
} else if ($lockMode == LockMode::PESSIMISTIC_WRITE) {
|
||||||
$lockSql = ' ' . $this->_platform->getWriteLockSql();
|
$lockSql = ' ' . $this->platform->getWriteLockSql();
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->_platform->modifyLimitQuery('SELECT ' . $this->_selectColumnListSql
|
return $this->platform->modifyLimitQuery('SELECT ' . $this->selectColumnListSql
|
||||||
. ' FROM ' . $this->quoteStrategy->getTableName($this->_class, $this->_platform) . ' ' . $baseTableAlias
|
. ' FROM ' . $this->quoteStrategy->getTableName($this->class, $this->platform) . ' ' . $baseTableAlias
|
||||||
. $joinSql
|
. $joinSql
|
||||||
. ($conditionSql != '' ? ' WHERE ' . $conditionSql : '') . $orderBySql, $limit, $offset)
|
. ($conditionSql != '' ? ' WHERE ' . $conditionSql : '') . $orderBySql, $limit, $offset)
|
||||||
. $lockSql;
|
. $lockSql;
|
||||||
@ -417,16 +417,16 @@ class JoinedSubclassPersister extends AbstractEntityInheritancePersister
|
|||||||
*/
|
*/
|
||||||
public function getLockTablesSql()
|
public function getLockTablesSql()
|
||||||
{
|
{
|
||||||
$idColumns = $this->_class->getIdentifierColumnNames();
|
$idColumns = $this->class->getIdentifierColumnNames();
|
||||||
$baseTableAlias = $this->_getSQLTableAlias($this->_class->name);
|
$baseTableAlias = $this->getSQLTableAlias($this->class->name);
|
||||||
|
|
||||||
// INNER JOIN parent tables
|
// INNER JOIN parent tables
|
||||||
$joinSql = '';
|
$joinSql = '';
|
||||||
|
|
||||||
foreach ($this->_class->parentClasses as $parentClassName) {
|
foreach ($this->class->parentClasses as $parentClassName) {
|
||||||
$parentClass = $this->_em->getClassMetadata($parentClassName);
|
$parentClass = $this->em->getClassMetadata($parentClassName);
|
||||||
$tableAlias = $this->_getSQLTableAlias($parentClassName);
|
$tableAlias = $this->getSQLTableAlias($parentClassName);
|
||||||
$joinSql .= ' INNER JOIN ' . $this->quoteStrategy->getTableName($parentClass, $this->_platform) . ' ' . $tableAlias . ' ON ';
|
$joinSql .= ' INNER JOIN ' . $this->quoteStrategy->getTableName($parentClass, $this->platform) . ' ' . $tableAlias . ' ON ';
|
||||||
$first = true;
|
$first = true;
|
||||||
|
|
||||||
foreach ($idColumns as $idColumn) {
|
foreach ($idColumns as $idColumn) {
|
||||||
@ -436,45 +436,45 @@ class JoinedSubclassPersister extends AbstractEntityInheritancePersister
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return 'FROM ' .$this->quoteStrategy->getTableName($this->_class, $this->_platform) . ' ' . $baseTableAlias . $joinSql;
|
return 'FROM ' .$this->quoteStrategy->getTableName($this->class, $this->platform) . ' ' . $baseTableAlias . $joinSql;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Ensure this method is never called. This persister overrides _getSelectEntitiesSQL directly. */
|
/* Ensure this method is never called. This persister overrides _getSelectEntitiesSQL directly. */
|
||||||
protected function _getSelectColumnListSQL()
|
protected function getSelectColumnListSQL()
|
||||||
{
|
{
|
||||||
throw new \BadMethodCallException("Illegal invocation of ".__METHOD__.".");
|
throw new \BadMethodCallException("Illegal invocation of ".__METHOD__.".");
|
||||||
}
|
}
|
||||||
|
|
||||||
/** {@inheritdoc} */
|
/** {@inheritdoc} */
|
||||||
protected function _getInsertColumnList()
|
protected function getInsertColumnList()
|
||||||
{
|
{
|
||||||
// Identifier columns must always come first in the column list of subclasses.
|
// Identifier columns must always come first in the column list of subclasses.
|
||||||
$columns = $this->_class->parentClasses ? $this->_class->getIdentifierColumnNames() : array();
|
$columns = $this->class->parentClasses ? $this->class->getIdentifierColumnNames() : array();
|
||||||
|
|
||||||
foreach ($this->_class->reflFields as $name => $field) {
|
foreach ($this->class->reflFields as $name => $field) {
|
||||||
if (isset($this->_class->fieldMappings[$name]['inherited']) && ! isset($this->_class->fieldMappings[$name]['id'])
|
if (isset($this->class->fieldMappings[$name]['inherited']) && ! isset($this->class->fieldMappings[$name]['id'])
|
||||||
|| isset($this->_class->associationMappings[$name]['inherited'])
|
|| isset($this->class->associationMappings[$name]['inherited'])
|
||||||
|| ($this->_class->isVersioned && $this->_class->versionField == $name)) {
|
|| ($this->class->isVersioned && $this->class->versionField == $name)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isset($this->_class->associationMappings[$name])) {
|
if (isset($this->class->associationMappings[$name])) {
|
||||||
$assoc = $this->_class->associationMappings[$name];
|
$assoc = $this->class->associationMappings[$name];
|
||||||
if ($assoc['type'] & ClassMetadata::TO_ONE && $assoc['isOwningSide']) {
|
if ($assoc['type'] & ClassMetadata::TO_ONE && $assoc['isOwningSide']) {
|
||||||
foreach ($assoc['targetToSourceKeyColumns'] as $sourceCol) {
|
foreach ($assoc['targetToSourceKeyColumns'] as $sourceCol) {
|
||||||
$columns[] = $sourceCol;
|
$columns[] = $sourceCol;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if ($this->_class->name != $this->_class->rootEntityName ||
|
} else if ($this->class->name != $this->class->rootEntityName ||
|
||||||
! $this->_class->isIdGeneratorIdentity() || $this->_class->identifier[0] != $name) {
|
! $this->class->isIdGeneratorIdentity() || $this->class->identifier[0] != $name) {
|
||||||
$columns[] = $this->quoteStrategy->getColumnName($name, $this->_class, $this->_platform);
|
$columns[] = $this->quoteStrategy->getColumnName($name, $this->class, $this->platform);
|
||||||
$this->_columnTypes[$name] = $this->_class->fieldMappings[$name]['type'];
|
$this->columnTypes[$name] = $this->class->fieldMappings[$name]['type'];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add discriminator column if it is the topmost class.
|
// Add discriminator column if it is the topmost class.
|
||||||
if ($this->_class->name == $this->_class->rootEntityName) {
|
if ($this->class->name == $this->class->rootEntityName) {
|
||||||
$columns[] = $this->_class->discriminatorColumn['name'];
|
$columns[] = $this->class->discriminatorColumn['name'];
|
||||||
}
|
}
|
||||||
|
|
||||||
return $columns;
|
return $columns;
|
||||||
@ -485,8 +485,8 @@ class JoinedSubclassPersister extends AbstractEntityInheritancePersister
|
|||||||
*/
|
*/
|
||||||
protected function assignDefaultVersionValue($entity, $id)
|
protected function assignDefaultVersionValue($entity, $id)
|
||||||
{
|
{
|
||||||
$value = $this->fetchVersionValue($this->_getVersionedClassMetadata(), $id);
|
$value = $this->fetchVersionValue($this->getVersionedClassMetadata(), $id);
|
||||||
$this->_class->setFieldValue($entity, $this->_class->versionField, $value);
|
$this->class->setFieldValue($entity, $this->class->versionField, $value);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -35,40 +35,40 @@ use Doctrine\Common\Collections\Criteria;
|
|||||||
class SingleTablePersister extends AbstractEntityInheritancePersister
|
class SingleTablePersister extends AbstractEntityInheritancePersister
|
||||||
{
|
{
|
||||||
/** {@inheritdoc} */
|
/** {@inheritdoc} */
|
||||||
protected function _getDiscriminatorColumnTableName()
|
protected function getDiscriminatorColumnTableName()
|
||||||
{
|
{
|
||||||
return $this->_class->getTableName();
|
return $this->class->getTableName();
|
||||||
}
|
}
|
||||||
|
|
||||||
/** {@inheritdoc} */
|
/** {@inheritdoc} */
|
||||||
protected function _getSelectColumnListSQL()
|
protected function getSelectColumnListSQL()
|
||||||
{
|
{
|
||||||
if ($this->_selectColumnListSql !== null) {
|
if ($this->selectColumnListSql !== null) {
|
||||||
return $this->_selectColumnListSql;
|
return $this->selectColumnListSql;
|
||||||
}
|
}
|
||||||
|
|
||||||
$columnList = parent::_getSelectColumnListSQL();
|
$columnList = parent::getSelectColumnListSQL();
|
||||||
|
|
||||||
$rootClass = $this->_em->getClassMetadata($this->_class->rootEntityName);
|
$rootClass = $this->em->getClassMetadata($this->class->rootEntityName);
|
||||||
$tableAlias = $this->_getSQLTableAlias($rootClass->name);
|
$tableAlias = $this->getSQLTableAlias($rootClass->name);
|
||||||
|
|
||||||
// Append discriminator column
|
// Append discriminator column
|
||||||
$discrColumn = $this->_class->discriminatorColumn['name'];
|
$discrColumn = $this->class->discriminatorColumn['name'];
|
||||||
$columnList .= ', ' . $tableAlias . '.' . $discrColumn;
|
$columnList .= ', ' . $tableAlias . '.' . $discrColumn;
|
||||||
|
|
||||||
$resultColumnName = $this->_platform->getSQLResultCasing($discrColumn);
|
$resultColumnName = $this->platform->getSQLResultCasing($discrColumn);
|
||||||
|
|
||||||
$this->_rsm->setDiscriminatorColumn('r', $resultColumnName);
|
$this->rsm->setDiscriminatorColumn('r', $resultColumnName);
|
||||||
$this->_rsm->addMetaResult('r', $resultColumnName, $discrColumn);
|
$this->rsm->addMetaResult('r', $resultColumnName, $discrColumn);
|
||||||
|
|
||||||
// Append subclass columns
|
// Append subclass columns
|
||||||
foreach ($this->_class->subClasses as $subClassName) {
|
foreach ($this->class->subClasses as $subClassName) {
|
||||||
$subClass = $this->_em->getClassMetadata($subClassName);
|
$subClass = $this->em->getClassMetadata($subClassName);
|
||||||
|
|
||||||
// Regular columns
|
// Regular columns
|
||||||
foreach ($subClass->fieldMappings as $fieldName => $mapping) {
|
foreach ($subClass->fieldMappings as $fieldName => $mapping) {
|
||||||
if ( ! isset($mapping['inherited'])) {
|
if ( ! isset($mapping['inherited'])) {
|
||||||
$columnList .= ', ' . $this->_getSelectColumnSQL($fieldName, $subClass);
|
$columnList .= ', ' . $this->getSelectColumnSQL($fieldName, $subClass);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -81,73 +81,73 @@ class SingleTablePersister extends AbstractEntityInheritancePersister
|
|||||||
$columnList .= $this->getSelectJoinColumnSQL(
|
$columnList .= $this->getSelectJoinColumnSQL(
|
||||||
$tableAlias,
|
$tableAlias,
|
||||||
$srcColumn,
|
$srcColumn,
|
||||||
isset($assoc['inherited']) ? $assoc['inherited'] : $this->_class->name
|
isset($assoc['inherited']) ? $assoc['inherited'] : $this->class->name
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->_selectColumnListSql = $columnList;
|
$this->selectColumnListSql = $columnList;
|
||||||
return $this->_selectColumnListSql;
|
return $this->selectColumnListSql;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** {@inheritdoc} */
|
/** {@inheritdoc} */
|
||||||
protected function _getInsertColumnList()
|
protected function getInsertColumnList()
|
||||||
{
|
{
|
||||||
$columns = parent::_getInsertColumnList();
|
$columns = parent::getInsertColumnList();
|
||||||
|
|
||||||
// Add discriminator column to the INSERT SQL
|
// Add discriminator column to the INSERT SQL
|
||||||
$columns[] = $this->_class->discriminatorColumn['name'];
|
$columns[] = $this->class->discriminatorColumn['name'];
|
||||||
|
|
||||||
return $columns;
|
return $columns;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** {@inheritdoc} */
|
/** {@inheritdoc} */
|
||||||
protected function _getSQLTableAlias($className, $assocName = '')
|
protected function getSQLTableAlias($className, $assocName = '')
|
||||||
{
|
{
|
||||||
return parent::_getSQLTableAlias($this->_class->rootEntityName, $assocName);
|
return parent::getSQLTableAlias($this->class->rootEntityName, $assocName);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** {@inheritdoc} */
|
/** {@inheritdoc} */
|
||||||
protected function _getSelectConditionSQL(array $criteria, $assoc = null)
|
protected function getSelectConditionSQL(array $criteria, $assoc = null)
|
||||||
{
|
{
|
||||||
$conditionSql = parent::_getSelectConditionSQL($criteria, $assoc);
|
$conditionSql = parent::getSelectConditionSQL($criteria, $assoc);
|
||||||
|
|
||||||
if ($conditionSql) {
|
if ($conditionSql) {
|
||||||
$conditionSql .= ' AND ';
|
$conditionSql .= ' AND ';
|
||||||
}
|
}
|
||||||
|
|
||||||
return $conditionSql . $this->_getSelectConditionDiscriminatorValueSQL();
|
return $conditionSql . $this->getSelectConditionDiscriminatorValueSQL();
|
||||||
}
|
}
|
||||||
|
|
||||||
/** {@inheritdoc} */
|
/** {@inheritdoc} */
|
||||||
protected function _getSelectConditionCriteriaSQL(Criteria $criteria)
|
protected function getSelectConditionCriteriaSQL(Criteria $criteria)
|
||||||
{
|
{
|
||||||
$conditionSql = parent::_getSelectConditionCriteriaSQL($criteria);
|
$conditionSql = parent::getSelectConditionCriteriaSQL($criteria);
|
||||||
|
|
||||||
if ($conditionSql) {
|
if ($conditionSql) {
|
||||||
$conditionSql .= ' AND ';
|
$conditionSql .= ' AND ';
|
||||||
}
|
}
|
||||||
|
|
||||||
return $conditionSql . $this->_getSelectConditionDiscriminatorValueSQL();
|
return $conditionSql . $this->getSelectConditionDiscriminatorValueSQL();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function _getSelectConditionDiscriminatorValueSQL()
|
protected function getSelectConditionDiscriminatorValueSQL()
|
||||||
{
|
{
|
||||||
$values = array();
|
$values = array();
|
||||||
|
|
||||||
if ($this->_class->discriminatorValue !== null) { // discriminators can be 0
|
if ($this->class->discriminatorValue !== null) { // discriminators can be 0
|
||||||
$values[] = $this->_conn->quote($this->_class->discriminatorValue);
|
$values[] = $this->conn->quote($this->class->discriminatorValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
$discrValues = array_flip($this->_class->discriminatorMap);
|
$discrValues = array_flip($this->class->discriminatorMap);
|
||||||
|
|
||||||
foreach ($this->_class->subClasses as $subclassName) {
|
foreach ($this->class->subClasses as $subclassName) {
|
||||||
$values[] = $this->_conn->quote($discrValues[$subclassName]);
|
$values[] = $this->conn->quote($discrValues[$subclassName]);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->_getSQLTableAlias($this->_class->name) . '.' . $this->_class->discriminatorColumn['name']
|
return $this->getSQLTableAlias($this->class->name) . '.' . $this->class->discriminatorColumn['name']
|
||||||
. ' IN (' . implode(', ', $values) . ')';
|
. ' IN (' . implode(', ', $values) . ')';
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -155,7 +155,7 @@ class SingleTablePersister extends AbstractEntityInheritancePersister
|
|||||||
protected function generateFilterConditionSQL(ClassMetadata $targetEntity, $targetTableAlias)
|
protected function generateFilterConditionSQL(ClassMetadata $targetEntity, $targetTableAlias)
|
||||||
{
|
{
|
||||||
// Ensure that the filters are applied to the root entity of the inheritance tree
|
// Ensure that the filters are applied to the root entity of the inheritance tree
|
||||||
$targetEntity = $this->_em->getClassMetadata($targetEntity->rootEntityName);
|
$targetEntity = $this->em->getClassMetadata($targetEntity->rootEntityName);
|
||||||
// we dont care about the $targetTableAlias, in a STI there is only one table.
|
// we dont care about the $targetTableAlias, in a STI there is only one table.
|
||||||
|
|
||||||
return parent::generateFilterConditionSQL($targetEntity, $targetTableAlias);
|
return parent::generateFilterConditionSQL($targetEntity, $targetTableAlias);
|
||||||
|
@ -7,12 +7,12 @@ namespace Doctrine\Tests\Mocks;
|
|||||||
*/
|
*/
|
||||||
class EntityPersisterMock extends \Doctrine\ORM\Persisters\BasicEntityPersister
|
class EntityPersisterMock extends \Doctrine\ORM\Persisters\BasicEntityPersister
|
||||||
{
|
{
|
||||||
private $_inserts = array();
|
private $inserts = array();
|
||||||
private $_updates = array();
|
private $updates = array();
|
||||||
private $_deletes = array();
|
private $deletes = array();
|
||||||
private $_identityColumnValueCounter = 0;
|
private $identityColumnValueCounter = 0;
|
||||||
private $_mockIdGeneratorType;
|
private $mockIdGeneratorType;
|
||||||
private $_postInsertIds = array();
|
private $postInsertIds = array();
|
||||||
private $existsCalled = false;
|
private $existsCalled = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -22,11 +22,11 @@ class EntityPersisterMock extends \Doctrine\ORM\Persisters\BasicEntityPersister
|
|||||||
*/
|
*/
|
||||||
public function insert($entity)
|
public function insert($entity)
|
||||||
{
|
{
|
||||||
$this->_inserts[] = $entity;
|
$this->inserts[] = $entity;
|
||||||
if ( ! is_null($this->_mockIdGeneratorType) && $this->_mockIdGeneratorType == \Doctrine\ORM\Mapping\ClassMetadata::GENERATOR_TYPE_IDENTITY
|
if ( ! is_null($this->mockIdGeneratorType) && $this->mockIdGeneratorType == \Doctrine\ORM\Mapping\ClassMetadata::GENERATOR_TYPE_IDENTITY
|
||||||
|| $this->_class->isIdGeneratorIdentity()) {
|
|| $this->class->isIdGeneratorIdentity()) {
|
||||||
$id = $this->_identityColumnValueCounter++;
|
$id = $this->identityColumnValueCounter++;
|
||||||
$this->_postInsertIds[$id] = $entity;
|
$this->postInsertIds[$id] = $entity;
|
||||||
return $id;
|
return $id;
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
@ -34,11 +34,11 @@ class EntityPersisterMock extends \Doctrine\ORM\Persisters\BasicEntityPersister
|
|||||||
|
|
||||||
public function addInsert($entity)
|
public function addInsert($entity)
|
||||||
{
|
{
|
||||||
$this->_inserts[] = $entity;
|
$this->inserts[] = $entity;
|
||||||
if ( ! is_null($this->_mockIdGeneratorType) && $this->_mockIdGeneratorType == \Doctrine\ORM\Mapping\ClassMetadata::GENERATOR_TYPE_IDENTITY
|
if ( ! is_null($this->mockIdGeneratorType) && $this->mockIdGeneratorType == \Doctrine\ORM\Mapping\ClassMetadata::GENERATOR_TYPE_IDENTITY
|
||||||
|| $this->_class->isIdGeneratorIdentity()) {
|
|| $this->class->isIdGeneratorIdentity()) {
|
||||||
$id = $this->_identityColumnValueCounter++;
|
$id = $this->identityColumnValueCounter++;
|
||||||
$this->_postInsertIds[$id] = $entity;
|
$this->postInsertIds[$id] = $entity;
|
||||||
return $id;
|
return $id;
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
@ -46,17 +46,17 @@ class EntityPersisterMock extends \Doctrine\ORM\Persisters\BasicEntityPersister
|
|||||||
|
|
||||||
public function executeInserts()
|
public function executeInserts()
|
||||||
{
|
{
|
||||||
return $this->_postInsertIds;
|
return $this->postInsertIds;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function setMockIdGeneratorType($genType)
|
public function setMockIdGeneratorType($genType)
|
||||||
{
|
{
|
||||||
$this->_mockIdGeneratorType = $genType;
|
$this->mockIdGeneratorType = $genType;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function update($entity)
|
public function update($entity)
|
||||||
{
|
{
|
||||||
$this->_updates[] = $entity;
|
$this->updates[] = $entity;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function exists($entity, array $extraConditions = array())
|
public function exists($entity, array $extraConditions = array())
|
||||||
@ -66,31 +66,31 @@ class EntityPersisterMock extends \Doctrine\ORM\Persisters\BasicEntityPersister
|
|||||||
|
|
||||||
public function delete($entity)
|
public function delete($entity)
|
||||||
{
|
{
|
||||||
$this->_deletes[] = $entity;
|
$this->deletes[] = $entity;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getInserts()
|
public function getInserts()
|
||||||
{
|
{
|
||||||
return $this->_inserts;
|
return $this->inserts;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getUpdates()
|
public function getUpdates()
|
||||||
{
|
{
|
||||||
return $this->_updates;
|
return $this->updates;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getDeletes()
|
public function getDeletes()
|
||||||
{
|
{
|
||||||
return $this->_deletes;
|
return $this->deletes;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function reset()
|
public function reset()
|
||||||
{
|
{
|
||||||
$this->existsCalled = false;
|
$this->existsCalled = false;
|
||||||
$this->_identityColumnValueCounter = 0;
|
$this->identityColumnValueCounter = 0;
|
||||||
$this->_inserts = array();
|
$this->inserts = array();
|
||||||
$this->_updates = array();
|
$this->updates = array();
|
||||||
$this->_deletes = array();
|
$this->deletes = array();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function isExistsCalled()
|
public function isExistsCalled()
|
||||||
|
@ -38,7 +38,7 @@ class BasicEntityPersisterTypeValueSqlTest extends \Doctrine\Tests\OrmTestCase
|
|||||||
|
|
||||||
public function testGetInsertSQLUsesTypeValuesSQL()
|
public function testGetInsertSQLUsesTypeValuesSQL()
|
||||||
{
|
{
|
||||||
$method = new \ReflectionMethod($this->_persister, '_getInsertSQL');
|
$method = new \ReflectionMethod($this->_persister, 'getInsertSQL');
|
||||||
$method->setAccessible(true);
|
$method->setAccessible(true);
|
||||||
|
|
||||||
$sql = $method->invoke($this->_persister);
|
$sql = $method->invoke($this->_persister);
|
||||||
@ -69,7 +69,7 @@ class BasicEntityPersisterTypeValueSqlTest extends \Doctrine\Tests\OrmTestCase
|
|||||||
|
|
||||||
public function testGetSelectConditionSQLUsesTypeValuesSQL()
|
public function testGetSelectConditionSQLUsesTypeValuesSQL()
|
||||||
{
|
{
|
||||||
$method = new \ReflectionMethod($this->_persister, '_getSelectConditionSQL');
|
$method = new \ReflectionMethod($this->_persister, 'getSelectConditionSQL');
|
||||||
$method->setAccessible(true);
|
$method->setAccessible(true);
|
||||||
|
|
||||||
$sql = $method->invoke($this->_persister, array('customInteger' => 1, 'child' => 1));
|
$sql = $method->invoke($this->_persister, array('customInteger' => 1, 'child' => 1));
|
||||||
@ -83,7 +83,7 @@ class BasicEntityPersisterTypeValueSqlTest extends \Doctrine\Tests\OrmTestCase
|
|||||||
public function testStripNonAlphanumericCharactersFromSelectColumnListSQL()
|
public function testStripNonAlphanumericCharactersFromSelectColumnListSQL()
|
||||||
{
|
{
|
||||||
$persister = new BasicEntityPersister($this->_em, $this->_em->getClassMetadata('Doctrine\Tests\Models\Quote\SimpleEntity'));
|
$persister = new BasicEntityPersister($this->_em, $this->_em->getClassMetadata('Doctrine\Tests\Models\Quote\SimpleEntity'));
|
||||||
$method = new \ReflectionMethod($persister, '_getSelectColumnListSQL');
|
$method = new \ReflectionMethod($persister, 'getSelectColumnListSQL');
|
||||||
$method->setAccessible(true);
|
$method->setAccessible(true);
|
||||||
|
|
||||||
$this->assertEquals('t0."simple-entity-id" AS simpleentityid1, t0."simple-entity-value" AS simpleentityvalue2', $method->invoke($persister));
|
$this->assertEquals('t0."simple-entity-id" AS simpleentityid1, t0."simple-entity-value" AS simpleentityvalue2', $method->invoke($persister));
|
||||||
|
Loading…
x
Reference in New Issue
Block a user