1 |
<?php
|
2 |
/*
|
3 |
* $Id: Hydrate.php 3192 2007-11-19 17:55:23Z romanb $
|
4 |
*
|
5 |
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
6 |
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
7 |
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
8 |
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
9 |
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
10 |
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
11 |
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
12 |
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
13 |
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
14 |
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
15 |
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
16 |
*
|
17 |
* This software consists of voluntary contributions made by many individuals
|
18 |
* and is licensed under the LGPL. For more information, see
|
19 |
* <http://www.phpdoctrine.com>.
|
20 |
*/
|
21 |
|
22 |
/**
|
23 |
* Doctrine_Hydrator_Abstract
|
24 |
*
|
25 |
* @package Doctrine
|
26 |
* @subpackage Hydrate
|
27 |
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
|
28 |
* @link www.phpdoctrine.com
|
29 |
* @since 1.0
|
30 |
* @version $Revision: 3192 $
|
31 |
* @author Konsta Vesterinen <kvesteri@cc.hut.fi>
|
32 |
*/
|
33 |
abstract class Doctrine_Hydrator_Abstract extends Doctrine_Locator_Injectable
|
34 |
{
|
35 |
/**
|
36 |
* @var array $_aliasMap two dimensional array containing the map for query aliases
|
37 |
* Main keys are component aliases
|
38 |
*
|
39 |
* table table object associated with given alias
|
40 |
*
|
41 |
* relation the relation object owned by the parent
|
42 |
*
|
43 |
* parent the alias of the parent
|
44 |
*
|
45 |
* agg the aggregates of this component
|
46 |
*
|
47 |
* map the name of the column / aggregate value this
|
48 |
* component is mapped to a collection
|
49 |
*/
|
50 |
protected $_queryComponents = array();
|
51 |
|
52 |
/**
|
53 |
* The current hydration mode.
|
54 |
*/
|
55 |
protected $_hydrationMode = Doctrine::HYDRATE_RECORD;
|
56 |
|
57 |
/**
|
58 |
* constructor
|
59 |
*
|
60 |
* @param Doctrine_Connection|null $connection
|
61 |
*/
|
62 |
public function __construct() {}
|
63 |
|
64 |
/**
|
65 |
* Sets the fetchmode.
|
66 |
*
|
67 |
* @param integer $fetchmode One of the Doctrine::HYDRATE_* constants.
|
68 |
*/
|
69 |
public function setHydrationMode($hydrationMode)
|
70 |
{
|
71 |
$this->_hydrationMode = $hydrationMode;
|
72 |
}
|
73 |
|
74 |
/**
|
75 |
* setAliasMap
|
76 |
* sets the whole component alias map
|
77 |
*
|
78 |
* @param array $map alias map
|
79 |
* @return Doctrine_Hydrate this object
|
80 |
*/
|
81 |
public function setQueryComponents(array $queryComponents)
|
82 |
{
|
83 |
$this->_queryComponents = $queryComponents;
|
84 |
}
|
85 |
|
86 |
/**
|
87 |
* getAliasMap
|
88 |
* returns the component alias map
|
89 |
*
|
90 |
* @return array component alias map
|
91 |
*/
|
92 |
public function getQueryComponents()
|
93 |
{
|
94 |
return $this->_queryComponents;
|
95 |
}
|
96 |
|
97 |
/**
|
98 |
* parseData
|
99 |
* parses the data returned by statement object
|
100 |
*
|
101 |
* This is method defines the core of Doctrine object population algorithm
|
102 |
* hence this method strives to be as fast as possible
|
103 |
*
|
104 |
* The key idea is the loop over the rowset only once doing all the needed operations
|
105 |
* within this massive loop.
|
106 |
*
|
107 |
* @todo: Can we refactor this function so that it is not so long and
|
108 |
* nested?
|
109 |
*
|
110 |
* @param mixed $stmt
|
111 |
* @return array
|
112 |
*/
|
113 |
abstract public function hydrateResultSet($stmt, $tableAliases, $hydrationMode = null);
|
114 |
|
115 |
}
|