2009-04-09 22:12:48 +04:00
|
|
|
<?php
|
|
|
|
/*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
|
|
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
|
|
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
|
|
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
|
|
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
|
|
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
|
|
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
|
|
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
|
|
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
|
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
|
|
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
*
|
|
|
|
* This software consists of voluntary contributions made by many individuals
|
|
|
|
* and is licensed under the LGPL. For more information, see
|
|
|
|
* <http://www.doctrine-project.org>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
namespace Doctrine\ORM\Query;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* A ResultSetMapping describes how a result set of an SQL query maps to a Doctrine result.
|
|
|
|
*
|
2009-05-14 18:57:08 +04:00
|
|
|
* IMPORTANT NOTE:
|
2009-07-30 19:16:02 +04:00
|
|
|
* The properties of this class are only public for fast internal READ access and to (drastically)
|
|
|
|
* reduce the size of serialized instances for more effective caching due to better (un-)serialization
|
|
|
|
* performance.
|
2011-11-14 07:36:39 +04:00
|
|
|
*
|
2009-08-15 22:11:51 +04:00
|
|
|
* <b>Users should use the public methods.</b>
|
2009-05-14 18:57:08 +04:00
|
|
|
*
|
2009-04-09 22:12:48 +04:00
|
|
|
* @author Roman Borschel <roman@code-factory.org>
|
|
|
|
* @since 2.0
|
2009-12-19 16:38:54 +03:00
|
|
|
* @todo Think about whether the number of lookup maps can be reduced.
|
2009-04-09 22:12:48 +04:00
|
|
|
*/
|
|
|
|
class ResultSetMapping
|
|
|
|
{
|
2009-12-19 16:38:54 +03:00
|
|
|
/**
|
|
|
|
* @ignore
|
2011-11-14 07:36:39 +04:00
|
|
|
* @var boolean Whether the result is mixed (contains scalar values together with field values).
|
2009-12-19 16:38:54 +03:00
|
|
|
*/
|
2009-05-14 18:57:08 +04:00
|
|
|
public $isMixed = false;
|
2011-11-14 07:36:39 +04:00
|
|
|
|
2009-12-19 16:38:54 +03:00
|
|
|
/**
|
|
|
|
* @ignore
|
2011-11-14 07:36:39 +04:00
|
|
|
* @var array Maps alias names to class names.
|
2009-12-19 16:38:54 +03:00
|
|
|
*/
|
2009-05-14 18:57:08 +04:00
|
|
|
public $aliasMap = array();
|
2011-11-14 07:36:39 +04:00
|
|
|
|
2009-12-19 16:38:54 +03:00
|
|
|
/**
|
|
|
|
* @ignore
|
2011-11-14 07:36:39 +04:00
|
|
|
* @var array Maps alias names to related association field names.
|
2009-12-19 16:38:54 +03:00
|
|
|
*/
|
2009-05-14 18:57:08 +04:00
|
|
|
public $relationMap = array();
|
2011-11-14 07:36:39 +04:00
|
|
|
|
2009-12-19 16:38:54 +03:00
|
|
|
/**
|
|
|
|
* @ignore
|
2011-11-14 07:36:39 +04:00
|
|
|
* @var array Maps alias names to parent alias names.
|
2009-12-19 16:38:54 +03:00
|
|
|
*/
|
2009-05-14 18:57:08 +04:00
|
|
|
public $parentAliasMap = array();
|
2011-11-14 07:36:39 +04:00
|
|
|
|
2009-12-19 16:38:54 +03:00
|
|
|
/**
|
|
|
|
* @ignore
|
2011-11-14 07:36:39 +04:00
|
|
|
* @var array Maps column names in the result set to field names for each class.
|
2009-12-19 16:38:54 +03:00
|
|
|
*/
|
2009-05-14 18:57:08 +04:00
|
|
|
public $fieldMappings = array();
|
2011-11-14 07:36:39 +04:00
|
|
|
|
2009-12-19 16:38:54 +03:00
|
|
|
/**
|
|
|
|
* @ignore
|
2011-11-14 07:36:39 +04:00
|
|
|
* @var array Maps column names in the result set to the alias/field name to use in the mapped result.
|
2009-12-19 16:38:54 +03:00
|
|
|
*/
|
2009-05-14 18:57:08 +04:00
|
|
|
public $scalarMappings = array();
|
2011-11-14 07:36:39 +04:00
|
|
|
|
2012-01-14 05:46:59 +04:00
|
|
|
/**
|
|
|
|
* @ignore
|
|
|
|
* @var array Maps column names in the result set to the alias/field type to use in the mapped result.
|
|
|
|
*/
|
|
|
|
public $typeMappings = array();
|
|
|
|
|
2009-12-19 16:38:54 +03:00
|
|
|
/**
|
|
|
|
* @ignore
|
2011-11-14 07:36:39 +04:00
|
|
|
* @var array Maps entities in the result set to the alias name to use in the mapped result.
|
|
|
|
*/
|
|
|
|
public $entityMappings = array();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @ignore
|
|
|
|
* @var array Maps column names of meta columns (foreign keys, discriminator columns, ...) to field names.
|
2009-12-19 16:38:54 +03:00
|
|
|
*/
|
2009-07-20 19:30:54 +04:00
|
|
|
public $metaMappings = array();
|
2011-11-14 07:36:39 +04:00
|
|
|
|
2009-12-19 16:38:54 +03:00
|
|
|
/**
|
|
|
|
* @ignore
|
2011-11-14 07:36:39 +04:00
|
|
|
* @var array Maps column names in the result set to the alias they belong to.
|
2009-12-19 16:38:54 +03:00
|
|
|
*/
|
2009-05-14 18:57:08 +04:00
|
|
|
public $columnOwnerMap = array();
|
2011-11-14 07:36:39 +04:00
|
|
|
|
2009-12-19 16:38:54 +03:00
|
|
|
/**
|
|
|
|
* @ignore
|
2011-11-14 07:36:39 +04:00
|
|
|
* @var array List of columns in the result set that are used as discriminator columns.
|
2009-12-19 16:38:54 +03:00
|
|
|
*/
|
2009-05-14 18:57:08 +04:00
|
|
|
public $discriminatorColumns = array();
|
2011-11-14 07:36:39 +04:00
|
|
|
|
2009-12-19 16:38:54 +03:00
|
|
|
/**
|
|
|
|
* @ignore
|
2011-11-14 07:36:39 +04:00
|
|
|
* @var array Maps alias names to field names that should be used for indexing.
|
2009-12-19 16:38:54 +03:00
|
|
|
*/
|
2009-05-14 18:57:08 +04:00
|
|
|
public $indexByMap = array();
|
2011-11-14 07:36:39 +04:00
|
|
|
|
2009-12-19 16:38:54 +03:00
|
|
|
/**
|
|
|
|
* @ignore
|
2011-11-14 07:36:39 +04:00
|
|
|
* @var array Map from column names to class names that declare the field the column is mapped to.
|
2009-12-19 16:38:54 +03:00
|
|
|
*/
|
|
|
|
public $declaringClasses = array();
|
2011-11-14 07:36:39 +04:00
|
|
|
|
2011-05-18 01:42:24 +04:00
|
|
|
/**
|
2011-11-14 07:36:39 +04:00
|
|
|
* @var array This is necessary to hydrate derivate foreign keys correctly.
|
2011-05-18 01:42:24 +04:00
|
|
|
*/
|
|
|
|
public $isIdentifierColumn = array();
|
2009-04-09 22:12:48 +04:00
|
|
|
|
|
|
|
/**
|
2009-08-03 17:25:56 +04:00
|
|
|
* Adds an entity result to this ResultSetMapping.
|
2009-04-09 22:12:48 +04:00
|
|
|
*
|
2009-08-03 17:25:56 +04:00
|
|
|
* @param string $class The class name of the entity.
|
|
|
|
* @param string $alias The alias for the class. The alias must be unique among all entity
|
|
|
|
* results or joined entity results within this ResultSetMapping.
|
2011-11-14 07:36:39 +04:00
|
|
|
* @param string $resultAlias The result alias with which the entity result should be
|
|
|
|
* placed in the result structure.
|
2011-12-07 17:23:15 +04:00
|
|
|
* @return ResultSetMapping This ResultSetMapping instance.
|
2009-12-19 16:38:54 +03:00
|
|
|
* @todo Rename: addRootEntity
|
2009-04-09 22:12:48 +04:00
|
|
|
*/
|
2011-11-14 07:36:39 +04:00
|
|
|
public function addEntityResult($class, $alias, $resultAlias = null)
|
2009-04-09 22:12:48 +04:00
|
|
|
{
|
2009-05-14 18:57:08 +04:00
|
|
|
$this->aliasMap[$alias] = $class;
|
2011-11-14 07:36:39 +04:00
|
|
|
$this->entityMappings[$alias] = $resultAlias;
|
2011-11-15 21:14:57 +04:00
|
|
|
|
|
|
|
if ($resultAlias !== null) {
|
|
|
|
$this->isMixed = true;
|
|
|
|
}
|
2011-12-20 01:56:19 +04:00
|
|
|
|
2011-12-07 17:23:15 +04:00
|
|
|
return $this;
|
2009-04-12 23:02:12 +04:00
|
|
|
}
|
|
|
|
|
2009-05-14 22:34:12 +04:00
|
|
|
/**
|
2009-08-03 17:25:56 +04:00
|
|
|
* Sets a discriminator column for an entity result or joined entity result.
|
|
|
|
* The discriminator column will be used to determine the concrete class name to
|
|
|
|
* instantiate.
|
2009-05-14 22:34:12 +04:00
|
|
|
*
|
2009-08-03 17:25:56 +04:00
|
|
|
* @param string $alias The alias of the entity result or joined entity result the discriminator
|
|
|
|
* column should be used for.
|
|
|
|
* @param string $discrColumn The name of the discriminator column in the SQL result set.
|
2011-12-07 17:23:15 +04:00
|
|
|
* @return ResultSetMapping This ResultSetMapping instance.
|
2009-12-19 16:38:54 +03:00
|
|
|
* @todo Rename: addDiscriminatorColumn
|
2009-05-14 22:34:12 +04:00
|
|
|
*/
|
2009-05-26 15:30:07 +04:00
|
|
|
public function setDiscriminatorColumn($alias, $discrColumn)
|
2009-04-12 23:02:12 +04:00
|
|
|
{
|
2009-05-26 15:30:07 +04:00
|
|
|
$this->discriminatorColumns[$alias] = $discrColumn;
|
2009-05-14 18:57:08 +04:00
|
|
|
$this->columnOwnerMap[$discrColumn] = $alias;
|
2011-12-20 01:56:19 +04:00
|
|
|
|
2011-12-07 17:23:15 +04:00
|
|
|
return $this;
|
2009-04-12 23:02:12 +04:00
|
|
|
}
|
|
|
|
|
2009-05-14 22:34:12 +04:00
|
|
|
/**
|
2009-08-03 17:25:56 +04:00
|
|
|
* Sets a field to use for indexing an entity result or joined entity result.
|
2009-05-14 22:34:12 +04:00
|
|
|
*
|
2009-08-03 17:25:56 +04:00
|
|
|
* @param string $alias The alias of an entity result or joined entity result.
|
|
|
|
* @param string $fieldName The name of the field to use for indexing.
|
2011-12-07 17:23:15 +04:00
|
|
|
* @return ResultSetMapping This ResultSetMapping instance.
|
2009-05-14 22:34:12 +04:00
|
|
|
*/
|
2009-04-09 22:12:48 +04:00
|
|
|
public function addIndexBy($alias, $fieldName)
|
|
|
|
{
|
2011-10-16 21:23:20 +04:00
|
|
|
$found = false;
|
2011-11-14 07:36:39 +04:00
|
|
|
|
2011-10-16 21:23:20 +04:00
|
|
|
foreach ($this->fieldMappings AS $columnName => $columnFieldName) {
|
2011-11-14 07:36:39 +04:00
|
|
|
if ( ! ($columnFieldName === $fieldName && $this->columnOwnerMap[$columnName] === $alias)) continue;
|
|
|
|
|
|
|
|
$this->addIndexByColumn($alias, $columnName);
|
|
|
|
$found = true;
|
|
|
|
|
|
|
|
break;
|
2011-10-16 21:23:20 +04:00
|
|
|
}
|
2011-12-07 18:31:23 +04:00
|
|
|
|
2011-11-08 16:15:09 +04:00
|
|
|
/* TODO: check if this exception can be put back, for now it's gone because of assumptions made by some ORM internals
|
2011-11-14 07:36:39 +04:00
|
|
|
if ( ! $found) {
|
|
|
|
$message = sprintf(
|
|
|
|
'Cannot add index by for DQL alias %s and field %s without calling addFieldResult() for them before.',
|
|
|
|
$alias,
|
|
|
|
$fieldName
|
|
|
|
);
|
|
|
|
|
|
|
|
throw new \LogicException($message);
|
2011-10-16 21:23:20 +04:00
|
|
|
}
|
2011-11-14 07:36:39 +04:00
|
|
|
*/
|
2011-12-20 01:56:19 +04:00
|
|
|
|
2011-12-07 18:16:27 +04:00
|
|
|
return $this;
|
2011-10-16 21:23:20 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Set to index by a scalar result column name
|
|
|
|
*
|
|
|
|
* @param $resultColumnName
|
2011-12-07 17:23:15 +04:00
|
|
|
* @return ResultSetMapping This ResultSetMapping instance.
|
2011-10-16 21:23:20 +04:00
|
|
|
*/
|
|
|
|
public function addIndexByScalar($resultColumnName)
|
|
|
|
{
|
|
|
|
$this->indexByMap['scalars'] = $resultColumnName;
|
2011-12-20 01:56:19 +04:00
|
|
|
|
2011-12-07 17:23:15 +04:00
|
|
|
return $this;
|
2011-10-16 21:23:20 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Sets a column to use for indexing an entity or joined entity result by the given alias name.
|
|
|
|
*
|
|
|
|
* @param $alias
|
|
|
|
* @param $resultColumnName
|
2011-12-07 17:23:15 +04:00
|
|
|
* @return ResultSetMapping This ResultSetMapping instance.
|
2011-10-16 21:23:20 +04:00
|
|
|
*/
|
|
|
|
public function addIndexByColumn($alias, $resultColumnName)
|
|
|
|
{
|
|
|
|
$this->indexByMap[$alias] = $resultColumnName;
|
2011-12-20 01:56:19 +04:00
|
|
|
|
2011-12-07 17:23:15 +04:00
|
|
|
return $this;
|
2009-04-09 22:12:48 +04:00
|
|
|
}
|
|
|
|
|
2009-05-14 22:34:12 +04:00
|
|
|
/**
|
2009-08-03 17:25:56 +04:00
|
|
|
* Checks whether an entity result or joined entity result with a given alias has
|
|
|
|
* a field set for indexing.
|
2009-05-14 22:34:12 +04:00
|
|
|
*
|
|
|
|
* @param string $alias
|
|
|
|
* @return boolean
|
2010-03-05 19:35:00 +03:00
|
|
|
* @todo Rename: isIndexed($alias)
|
2009-05-14 22:34:12 +04:00
|
|
|
*/
|
2009-04-09 22:12:48 +04:00
|
|
|
public function hasIndexBy($alias)
|
|
|
|
{
|
2009-05-14 18:57:08 +04:00
|
|
|
return isset($this->indexByMap[$alias]);
|
2009-04-09 22:12:48 +04:00
|
|
|
}
|
|
|
|
|
2009-05-14 22:34:12 +04:00
|
|
|
/**
|
2009-08-03 17:25:56 +04:00
|
|
|
* Checks whether the column with the given name is mapped as a field result
|
|
|
|
* as part of an entity result or joined entity result.
|
2009-05-14 22:34:12 +04:00
|
|
|
*
|
2009-08-03 17:25:56 +04:00
|
|
|
* @param string $columnName The name of the column in the SQL result set.
|
2009-05-14 22:34:12 +04:00
|
|
|
* @return boolean
|
2009-12-19 16:38:54 +03:00
|
|
|
* @todo Rename: isField
|
2009-05-14 22:34:12 +04:00
|
|
|
*/
|
2009-04-12 23:02:12 +04:00
|
|
|
public function isFieldResult($columnName)
|
|
|
|
{
|
2009-05-14 18:57:08 +04:00
|
|
|
return isset($this->fieldMappings[$columnName]);
|
2009-04-12 23:02:12 +04:00
|
|
|
}
|
|
|
|
|
2009-05-14 22:34:12 +04:00
|
|
|
/**
|
2009-12-19 16:38:54 +03:00
|
|
|
* Adds a field to the result that belongs to an entity or joined entity.
|
2009-05-14 22:34:12 +04:00
|
|
|
*
|
2009-12-19 16:38:54 +03:00
|
|
|
* @param string $alias The alias of the root entity or joined entity to which the field belongs.
|
2009-08-03 17:25:56 +04:00
|
|
|
* @param string $columnName The name of the column in the SQL result set.
|
2009-12-19 16:38:54 +03:00
|
|
|
* @param string $fieldName The name of the field on the declaring class.
|
|
|
|
* @param string $declaringClass The name of the class that declares/owns the specified field.
|
|
|
|
* When $alias refers to a superclass in a mapped hierarchy but
|
|
|
|
* the field $fieldName is defined on a subclass, specify that here.
|
|
|
|
* If not specified, the field is assumed to belong to the class
|
|
|
|
* designated by $alias.
|
2011-12-07 17:23:15 +04:00
|
|
|
* @return ResultSetMapping This ResultSetMapping instance.
|
2009-12-19 16:38:54 +03:00
|
|
|
* @todo Rename: addField
|
2009-05-14 22:34:12 +04:00
|
|
|
*/
|
2009-12-19 16:38:54 +03:00
|
|
|
public function addFieldResult($alias, $columnName, $fieldName, $declaringClass = null)
|
2009-04-09 22:12:48 +04:00
|
|
|
{
|
2009-12-19 16:38:54 +03:00
|
|
|
// column name (in result set) => field name
|
2009-05-14 18:57:08 +04:00
|
|
|
$this->fieldMappings[$columnName] = $fieldName;
|
2009-12-19 16:38:54 +03:00
|
|
|
// column name => alias of owner
|
2009-05-14 18:57:08 +04:00
|
|
|
$this->columnOwnerMap[$columnName] = $alias;
|
2009-12-19 16:38:54 +03:00
|
|
|
// field name => class name of declaring class
|
|
|
|
$this->declaringClasses[$columnName] = $declaringClass ?: $this->aliasMap[$alias];
|
2011-11-14 07:36:39 +04:00
|
|
|
|
2009-05-14 18:57:08 +04:00
|
|
|
if ( ! $this->isMixed && $this->scalarMappings) {
|
|
|
|
$this->isMixed = true;
|
2009-04-12 23:02:12 +04:00
|
|
|
}
|
2011-12-20 01:56:19 +04:00
|
|
|
|
2011-12-07 17:23:15 +04:00
|
|
|
return $this;
|
2009-04-09 22:12:48 +04:00
|
|
|
}
|
|
|
|
|
2009-05-14 22:34:12 +04:00
|
|
|
/**
|
2009-08-03 17:25:56 +04:00
|
|
|
* Adds a joined entity result.
|
2009-05-14 22:34:12 +04:00
|
|
|
*
|
2009-08-03 17:25:56 +04:00
|
|
|
* @param string $class The class name of the joined entity.
|
|
|
|
* @param string $alias The unique alias to use for the joined entity.
|
|
|
|
* @param string $parentAlias The alias of the entity result that is the parent of this joined result.
|
2009-08-15 22:11:51 +04:00
|
|
|
* @param object $relation The association field that connects the parent entity result with the joined entity result.
|
2011-12-07 17:23:15 +04:00
|
|
|
* @return ResultSetMapping This ResultSetMapping instance.
|
2009-12-19 16:38:54 +03:00
|
|
|
* @todo Rename: addJoinedEntity
|
2009-05-14 22:34:12 +04:00
|
|
|
*/
|
2009-04-12 23:02:12 +04:00
|
|
|
public function addJoinedEntityResult($class, $alias, $parentAlias, $relation)
|
2009-04-09 22:12:48 +04:00
|
|
|
{
|
2011-11-14 07:36:39 +04:00
|
|
|
$this->aliasMap[$alias] = $class;
|
2009-05-14 18:57:08 +04:00
|
|
|
$this->parentAliasMap[$alias] = $parentAlias;
|
2011-11-14 07:36:39 +04:00
|
|
|
$this->relationMap[$alias] = $relation;
|
2011-12-20 01:56:19 +04:00
|
|
|
|
2011-12-07 17:23:15 +04:00
|
|
|
return $this;
|
2009-04-09 22:12:48 +04:00
|
|
|
}
|
2011-11-14 07:36:39 +04:00
|
|
|
|
2009-05-28 15:13:12 +04:00
|
|
|
/**
|
2009-08-03 17:25:56 +04:00
|
|
|
* Adds a scalar result mapping.
|
2009-05-28 15:13:12 +04:00
|
|
|
*
|
2009-08-03 17:25:56 +04:00
|
|
|
* @param string $columnName The name of the column in the SQL result set.
|
2009-08-15 22:11:51 +04:00
|
|
|
* @param string $alias The result alias with which the scalar result should be placed in the result structure.
|
2012-01-14 05:46:59 +04:00
|
|
|
* @param string $type The column type
|
|
|
|
*
|
2011-12-07 17:23:15 +04:00
|
|
|
* @return ResultSetMapping This ResultSetMapping instance.
|
2012-01-14 05:46:59 +04:00
|
|
|
*
|
2009-12-19 16:38:54 +03:00
|
|
|
* @todo Rename: addScalar
|
2009-05-28 15:13:12 +04:00
|
|
|
*/
|
2012-01-16 23:26:13 +04:00
|
|
|
public function addScalarResult($columnName, $alias, $type = 'string')
|
2009-04-09 22:12:48 +04:00
|
|
|
{
|
2009-05-14 18:57:08 +04:00
|
|
|
$this->scalarMappings[$columnName] = $alias;
|
2012-01-16 23:26:13 +04:00
|
|
|
$this->typeMappings[$columnName] = $type;
|
2011-11-14 07:36:39 +04:00
|
|
|
|
2009-05-14 18:57:08 +04:00
|
|
|
if ( ! $this->isMixed && $this->fieldMappings) {
|
|
|
|
$this->isMixed = true;
|
2009-04-12 23:02:12 +04:00
|
|
|
}
|
2011-12-20 01:56:19 +04:00
|
|
|
|
2011-12-07 17:23:15 +04:00
|
|
|
return $this;
|
2009-07-19 20:54:53 +04:00
|
|
|
}
|
2009-04-09 22:12:48 +04:00
|
|
|
|
|
|
|
/**
|
2009-08-03 17:25:56 +04:00
|
|
|
* Checks whether a column with a given name is mapped as a scalar result.
|
2011-11-14 07:36:39 +04:00
|
|
|
*
|
2009-08-03 17:25:56 +04:00
|
|
|
* @param string $columName The name of the column in the SQL result set.
|
2009-04-09 22:12:48 +04:00
|
|
|
* @return boolean
|
2009-12-19 16:38:54 +03:00
|
|
|
* @todo Rename: isScalar
|
2009-04-09 22:12:48 +04:00
|
|
|
*/
|
|
|
|
public function isScalarResult($columnName)
|
|
|
|
{
|
2009-05-14 18:57:08 +04:00
|
|
|
return isset($this->scalarMappings[$columnName]);
|
2009-04-09 22:12:48 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2009-08-03 17:25:56 +04:00
|
|
|
* Gets the name of the class of an entity result or joined entity result,
|
|
|
|
* identified by the given unique alias.
|
2009-04-09 22:12:48 +04:00
|
|
|
*
|
2009-08-03 17:25:56 +04:00
|
|
|
* @param string $alias
|
|
|
|
* @return string
|
2009-04-09 22:12:48 +04:00
|
|
|
*/
|
2009-08-03 17:25:56 +04:00
|
|
|
public function getClassName($alias)
|
2009-04-09 22:12:48 +04:00
|
|
|
{
|
2009-05-14 18:57:08 +04:00
|
|
|
return $this->aliasMap[$alias];
|
2009-04-09 22:12:48 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2009-08-03 17:25:56 +04:00
|
|
|
* Gets the field alias for a column that is mapped as a scalar value.
|
2009-04-09 22:12:48 +04:00
|
|
|
*
|
2009-08-03 17:25:56 +04:00
|
|
|
* @param string $columnName The name of the column in the SQL result set.
|
2009-04-09 22:12:48 +04:00
|
|
|
* @return string
|
|
|
|
*/
|
|
|
|
public function getScalarAlias($columnName)
|
|
|
|
{
|
2009-05-14 18:57:08 +04:00
|
|
|
return $this->scalarMappings[$columnName];
|
2009-04-09 22:12:48 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2009-08-03 17:25:56 +04:00
|
|
|
* Gets the name of the class that owns a field mapping for the specified column.
|
2009-04-09 22:12:48 +04:00
|
|
|
*
|
|
|
|
* @param string $columnName
|
2009-08-03 17:25:56 +04:00
|
|
|
* @return string
|
2009-04-09 22:12:48 +04:00
|
|
|
*/
|
2009-12-19 16:38:54 +03:00
|
|
|
public function getDeclaringClass($columnName)
|
2009-04-09 22:12:48 +04:00
|
|
|
{
|
2009-12-19 16:38:54 +03:00
|
|
|
return $this->declaringClasses[$columnName];
|
2009-04-09 22:12:48 +04:00
|
|
|
}
|
|
|
|
|
2009-05-14 22:34:12 +04:00
|
|
|
/**
|
|
|
|
*
|
|
|
|
* @param string $alias
|
|
|
|
* @return AssociationMapping
|
|
|
|
*/
|
2009-04-09 22:12:48 +04:00
|
|
|
public function getRelation($alias)
|
|
|
|
{
|
2009-05-14 18:57:08 +04:00
|
|
|
return $this->relationMap[$alias];
|
2009-04-09 22:12:48 +04:00
|
|
|
}
|
|
|
|
|
2009-05-14 22:34:12 +04:00
|
|
|
/**
|
|
|
|
*
|
|
|
|
* @param string $alias
|
|
|
|
* @return boolean
|
|
|
|
*/
|
2009-05-13 19:19:27 +04:00
|
|
|
public function isRelation($alias)
|
|
|
|
{
|
2009-05-14 18:57:08 +04:00
|
|
|
return isset($this->relationMap[$alias]);
|
2009-05-13 19:19:27 +04:00
|
|
|
}
|
|
|
|
|
2009-04-09 22:12:48 +04:00
|
|
|
/**
|
2009-08-03 17:25:56 +04:00
|
|
|
* Gets the alias of the class that owns a field mapping for the specified column.
|
2009-04-09 22:12:48 +04:00
|
|
|
*
|
2009-08-03 17:25:56 +04:00
|
|
|
* @param string $columnName
|
|
|
|
* @return string
|
2009-04-09 22:12:48 +04:00
|
|
|
*/
|
|
|
|
public function getEntityAlias($columnName)
|
|
|
|
{
|
2009-05-14 18:57:08 +04:00
|
|
|
return $this->columnOwnerMap[$columnName];
|
2009-04-09 22:12:48 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2009-08-03 17:25:56 +04:00
|
|
|
* Gets the parent alias of the given alias.
|
2009-04-09 22:12:48 +04:00
|
|
|
*
|
2009-05-14 22:34:12 +04:00
|
|
|
* @param string $alias
|
|
|
|
* @return string
|
2009-04-09 22:12:48 +04:00
|
|
|
*/
|
|
|
|
public function getParentAlias($alias)
|
|
|
|
{
|
2009-05-14 18:57:08 +04:00
|
|
|
return $this->parentAliasMap[$alias];
|
2009-04-09 22:12:48 +04:00
|
|
|
}
|
|
|
|
|
2009-05-14 22:34:12 +04:00
|
|
|
/**
|
2009-08-03 17:25:56 +04:00
|
|
|
* Checks whether the given alias has a parent alias.
|
2009-05-14 22:34:12 +04:00
|
|
|
*
|
|
|
|
* @param string $alias
|
|
|
|
* @return boolean
|
|
|
|
*/
|
2009-04-09 22:12:48 +04:00
|
|
|
public function hasParentAlias($alias)
|
|
|
|
{
|
2009-05-14 18:57:08 +04:00
|
|
|
return isset($this->parentAliasMap[$alias]);
|
2009-04-09 22:12:48 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2009-05-14 22:34:12 +04:00
|
|
|
* Gets the field name for a column name.
|
2009-04-09 22:12:48 +04:00
|
|
|
*
|
2009-05-14 22:34:12 +04:00
|
|
|
* @param string $columnName
|
|
|
|
* @return string
|
2009-04-09 22:12:48 +04:00
|
|
|
*/
|
|
|
|
public function getFieldName($columnName)
|
|
|
|
{
|
2009-05-14 18:57:08 +04:00
|
|
|
return $this->fieldMappings[$columnName];
|
2009-04-09 22:12:48 +04:00
|
|
|
}
|
|
|
|
|
2009-05-14 22:34:12 +04:00
|
|
|
/**
|
|
|
|
*
|
|
|
|
* @return array
|
|
|
|
*/
|
2009-04-09 22:12:48 +04:00
|
|
|
public function getAliasMap()
|
|
|
|
{
|
2009-05-14 18:57:08 +04:00
|
|
|
return $this->aliasMap;
|
2009-04-09 22:12:48 +04:00
|
|
|
}
|
|
|
|
|
2009-05-14 22:34:12 +04:00
|
|
|
/**
|
2009-08-03 17:25:56 +04:00
|
|
|
* Gets the number of different entities that appear in the mapped result.
|
2009-05-14 22:34:12 +04:00
|
|
|
*
|
|
|
|
* @return integer
|
|
|
|
*/
|
2009-04-09 22:12:48 +04:00
|
|
|
public function getEntityResultCount()
|
|
|
|
{
|
2009-05-14 18:57:08 +04:00
|
|
|
return count($this->aliasMap);
|
2009-04-09 22:12:48 +04:00
|
|
|
}
|
2009-04-12 23:02:12 +04:00
|
|
|
|
2009-05-14 22:34:12 +04:00
|
|
|
/**
|
2009-07-20 19:30:54 +04:00
|
|
|
* Checks whether this ResultSetMapping defines a mixed result.
|
|
|
|
* Mixed results can only occur in object and array (graph) hydration. In such a
|
|
|
|
* case a mixed result means that scalar values are mixed with objects/array in
|
|
|
|
* the result.
|
2009-05-14 22:34:12 +04:00
|
|
|
*
|
|
|
|
* @return boolean
|
|
|
|
*/
|
2009-04-12 23:02:12 +04:00
|
|
|
public function isMixedResult()
|
|
|
|
{
|
2009-05-14 18:57:08 +04:00
|
|
|
return $this->isMixed;
|
2009-04-12 23:02:12 +04:00
|
|
|
}
|
2011-11-14 07:36:39 +04:00
|
|
|
|
2009-07-20 19:30:54 +04:00
|
|
|
/**
|
2010-03-05 19:35:00 +03:00
|
|
|
* Adds a meta column (foreign key or discriminator column) to the result set.
|
2011-11-14 07:36:39 +04:00
|
|
|
*
|
2011-05-18 01:42:24 +04:00
|
|
|
* @param string $alias
|
|
|
|
* @param string $columnName
|
|
|
|
* @param string $fieldName
|
|
|
|
* @param bool
|
2011-12-07 17:23:15 +04:00
|
|
|
* @return ResultSetMapping This ResultSetMapping instance.
|
2009-07-20 19:30:54 +04:00
|
|
|
*/
|
2011-05-18 01:42:24 +04:00
|
|
|
public function addMetaResult($alias, $columnName, $fieldName, $isIdentifierColumn = false)
|
2009-07-20 19:30:54 +04:00
|
|
|
{
|
|
|
|
$this->metaMappings[$columnName] = $fieldName;
|
|
|
|
$this->columnOwnerMap[$columnName] = $alias;
|
2011-11-14 07:36:39 +04:00
|
|
|
|
2011-05-18 01:42:24 +04:00
|
|
|
if ($isIdentifierColumn) {
|
|
|
|
$this->isIdentifierColumn[$alias][$columnName] = true;
|
|
|
|
}
|
2011-12-20 01:56:19 +04:00
|
|
|
|
2011-12-07 17:23:15 +04:00
|
|
|
return $this;
|
2009-07-20 19:30:54 +04:00
|
|
|
}
|
2011-11-08 16:15:09 +04:00
|
|
|
}
|