2007-11-20 17:26:42 +03:00
|
|
|
<?php
|
|
|
|
/*
|
|
|
|
* $Id: Hydrate.php 3192 2007-11-19 17:55:23Z romanb $
|
|
|
|
*
|
|
|
|
* 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
|
2008-01-23 01:52:53 +03:00
|
|
|
* <http://www.phpdoctrine.org>.
|
2007-11-20 17:26:42 +03:00
|
|
|
*/
|
|
|
|
|
2008-09-12 13:58:02 +04:00
|
|
|
#namespace Doctrine::ORM::Internal::Hydration;
|
|
|
|
|
2007-11-20 17:26:42 +03:00
|
|
|
/**
|
2008-07-27 23:38:56 +04:00
|
|
|
* Base class for all hydrators (ok, we got only 1 currently).
|
2007-11-20 17:26:42 +03:00
|
|
|
*
|
|
|
|
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
|
2008-02-22 21:11:35 +03:00
|
|
|
* @link www.phpdoctrine.org
|
2007-11-20 17:26:42 +03:00
|
|
|
* @since 1.0
|
|
|
|
* @version $Revision: 3192 $
|
|
|
|
* @author Konsta Vesterinen <kvesteri@cc.hut.fi>
|
2008-07-27 23:38:56 +04:00
|
|
|
* @author Roman Borschel <roman@code-factory.org>
|
2007-11-20 17:26:42 +03:00
|
|
|
*/
|
2008-09-12 13:58:02 +04:00
|
|
|
abstract class Doctrine_ORM_Internal_Hydration_AbstractHydrator
|
2007-11-20 17:26:42 +03:00
|
|
|
{
|
|
|
|
/**
|
2008-05-24 22:18:37 +04:00
|
|
|
* @var array $_queryComponents
|
2007-11-20 17:26:42 +03:00
|
|
|
*
|
2008-05-24 22:18:37 +04:00
|
|
|
* Two dimensional array containing the map for query aliases. Main keys are component aliases.
|
2007-11-20 17:26:42 +03:00
|
|
|
*
|
2008-05-24 22:18:37 +04:00
|
|
|
* table Table object associated with given alias.
|
|
|
|
* relation Relation object owned by the parent.
|
|
|
|
* parent Alias of the parent.
|
|
|
|
* agg Aggregates of this component.
|
|
|
|
* map Name of the column / aggregate value this component is mapped to a collection.
|
2007-11-20 17:26:42 +03:00
|
|
|
*/
|
2007-11-21 17:29:59 +03:00
|
|
|
protected $_queryComponents = array();
|
2007-11-20 17:26:42 +03:00
|
|
|
|
2008-05-24 22:18:37 +04:00
|
|
|
/**
|
|
|
|
* @var array Table alias map. Keys are SQL aliases and values DQL aliases.
|
|
|
|
*/
|
|
|
|
protected $_tableAliasMap = array();
|
|
|
|
|
2007-11-20 17:26:42 +03:00
|
|
|
/**
|
|
|
|
* The current hydration mode.
|
|
|
|
*/
|
|
|
|
protected $_hydrationMode = Doctrine::HYDRATE_RECORD;
|
2008-03-19 21:33:14 +03:00
|
|
|
|
|
|
|
protected $_nullObject;
|
2008-05-14 01:20:34 +04:00
|
|
|
|
|
|
|
protected $_em;
|
2007-11-20 17:26:42 +03:00
|
|
|
|
2008-05-24 22:18:37 +04:00
|
|
|
|
2007-11-20 17:26:42 +03:00
|
|
|
/**
|
2008-09-13 14:28:29 +04:00
|
|
|
* Constructor.
|
2007-11-20 17:26:42 +03:00
|
|
|
*
|
2008-09-13 14:28:29 +04:00
|
|
|
* @param Doctrine::ORM::EntityManager $em The EntityManager to use during hydration.
|
2007-11-20 17:26:42 +03:00
|
|
|
*/
|
2008-09-12 17:16:05 +04:00
|
|
|
public function __construct(Doctrine_ORM_EntityManager $em)
|
2008-03-19 21:33:14 +03:00
|
|
|
{
|
2008-05-14 01:20:34 +04:00
|
|
|
$this->_em = $em;
|
2008-09-12 12:59:44 +04:00
|
|
|
$this->_nullObject = Doctrine_ORM_Internal_Null::$INSTANCE;
|
2008-03-19 21:33:14 +03:00
|
|
|
}
|
2007-11-20 17:26:42 +03:00
|
|
|
|
|
|
|
/**
|
2008-05-24 22:18:37 +04:00
|
|
|
* setHydrationMode
|
|
|
|
*
|
|
|
|
* Defines the hydration process mode.
|
2007-11-20 17:26:42 +03:00
|
|
|
*
|
2008-05-24 22:18:37 +04:00
|
|
|
* @param integer $hydrationMode Doctrine processing mode to be used during hydration process.
|
|
|
|
* One of the Doctrine::HYDRATE_* constants.
|
2007-11-20 17:26:42 +03:00
|
|
|
*/
|
|
|
|
public function setHydrationMode($hydrationMode)
|
|
|
|
{
|
|
|
|
$this->_hydrationMode = $hydrationMode;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2008-05-24 22:18:37 +04:00
|
|
|
* setQueryComponents
|
|
|
|
*
|
|
|
|
* Defines the mapping components.
|
2007-11-20 17:26:42 +03:00
|
|
|
*
|
2008-05-24 22:18:37 +04:00
|
|
|
* @param array $queryComponents Query components.
|
2007-11-20 17:26:42 +03:00
|
|
|
*/
|
2007-11-21 17:29:59 +03:00
|
|
|
public function setQueryComponents(array $queryComponents)
|
2007-11-20 17:26:42 +03:00
|
|
|
{
|
2007-11-21 17:29:59 +03:00
|
|
|
$this->_queryComponents = $queryComponents;
|
2007-11-20 17:26:42 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2008-05-24 22:18:37 +04:00
|
|
|
* getQueryComponents
|
|
|
|
*
|
|
|
|
* Gets the mapping components.
|
2007-11-20 17:26:42 +03:00
|
|
|
*
|
2008-05-24 22:18:37 +04:00
|
|
|
* @return array Query components.
|
2007-11-20 17:26:42 +03:00
|
|
|
*/
|
2007-11-21 17:29:59 +03:00
|
|
|
public function getQueryComponents()
|
2007-11-20 17:26:42 +03:00
|
|
|
{
|
2007-11-21 17:29:59 +03:00
|
|
|
return $this->_queryComponents;
|
2007-11-20 17:26:42 +03:00
|
|
|
}
|
2008-05-24 22:18:37 +04:00
|
|
|
|
2008-01-16 17:29:11 +03:00
|
|
|
/**
|
2008-05-24 22:18:37 +04:00
|
|
|
* setTableAliasMap
|
2008-01-16 17:29:11 +03:00
|
|
|
*
|
2008-05-24 22:18:37 +04:00
|
|
|
* Defines the table aliases.
|
2008-01-16 17:29:11 +03:00
|
|
|
*
|
2008-05-24 22:18:37 +04:00
|
|
|
* @param array $tableAliasMap Table aliases.
|
2008-01-16 17:29:11 +03:00
|
|
|
*/
|
2008-05-24 22:18:37 +04:00
|
|
|
public function setTableAliasMap(array $tableAliasMap)
|
2008-01-16 17:29:11 +03:00
|
|
|
{
|
2008-05-24 22:18:37 +04:00
|
|
|
$this->_tableAliasMap = $tableAliasMap;
|
2008-01-16 17:29:11 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2008-05-24 22:18:37 +04:00
|
|
|
* getTableAliasMap
|
|
|
|
*
|
|
|
|
* Returns all table aliases.
|
2008-01-16 17:29:11 +03:00
|
|
|
*
|
2008-05-24 22:18:37 +04:00
|
|
|
* @return array Table aliases as an array.
|
2008-01-16 17:29:11 +03:00
|
|
|
*/
|
2008-05-24 22:18:37 +04:00
|
|
|
public function getTableAliasMap()
|
2008-01-16 17:29:11 +03:00
|
|
|
{
|
2008-05-24 22:18:37 +04:00
|
|
|
return $this->_tableAliasMap;
|
2008-01-16 17:29:11 +03:00
|
|
|
}
|
2007-11-20 17:26:42 +03:00
|
|
|
|
|
|
|
/**
|
2008-05-24 22:18:37 +04:00
|
|
|
* Processes data returned by statement object.
|
2007-11-20 17:26:42 +03:00
|
|
|
*
|
2008-09-13 14:28:29 +04:00
|
|
|
* This is method defines the core of Doctrine object/array population algorithm.
|
2007-11-20 17:26:42 +03:00
|
|
|
*
|
2008-05-24 22:18:37 +04:00
|
|
|
* @param mixed $stmt PDOStatement
|
|
|
|
* @param integer $hydrationMode Doctrine processing mode to be used during hydration process.
|
|
|
|
* One of the Doctrine::HYDRATE_* constants.
|
2008-09-13 14:28:29 +04:00
|
|
|
* @return mixed
|
2007-11-20 17:26:42 +03:00
|
|
|
*/
|
2008-05-14 01:20:34 +04:00
|
|
|
abstract public function hydrateResultSet($parserResult);
|
2007-11-20 17:26:42 +03:00
|
|
|
}
|