Subversion-Projekte lars-tiefland.php_share

Revision

Details | Letzte Änderung | Log anzeigen | RSS feed

Revision Autor Zeilennr. Zeile
1 lars 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.doctrine-project.org>.
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.doctrine-project.org
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
    protected
36
        $_queryComponents = array(),
37
        $_tableAliases = array(),
38
        $_priorRow,
39
        $_hydrationMode;
40
 
41
    public function __construct($queryComponents = null, $tableAliases = null, $hydrationMode = null)
42
    {
43
        $this->setQueryComponents($queryComponents);
44
        $this->setTableAliases($tableAliases);
45
        $this->setHydrationMode($hydrationMode);
46
    }
47
 
48
    /**
49
     * Set the query components (structure and query instructions)
50
     *
51
     * @param array $queryComponents
52
     * @return void
53
     */
54
    public function setQueryComponents($queryComponents)
55
    {
56
        $this->_queryComponents = $queryComponents;
57
    }
58
 
59
    /**
60
     * Set the table aliases for this query
61
     *
62
     * @param array $tableAliases
63
     * @return void
64
     */
65
    public function setTableAliases($tableAliases)
66
    {
67
        $this->_tableAliases = $tableAliases;
68
    }
69
 
70
    /**
71
     * Set the hydration mode
72
     *
73
     * @param mixed $hydrationMode  One of the Doctrine_Core::HYDRATE_* constants or
74
     *                              a string representing the name of the hydration mode or
75
     *                              or an instance of the hydration class
76
     * @return void
77
     */
78
    public function setHydrationMode($hydrationMode)
79
    {
80
        $this->_hydrationMode = $hydrationMode;
81
    }
82
 
83
    public function getRootComponent()
84
    {
85
        $queryComponents = array_values($this->_queryComponents);
86
        return $queryComponents[0]['table'];
87
    }
88
 
89
    public function onDemandReset()
90
    {
91
        $this->_priorRow = null;
92
    }
93
 
94
    /**
95
     * Checks whether a name is ignored. Used during result set parsing to skip
96
     * certain elements in the result set that do not have any meaning for the result.
97
     * (I.e. ORACLE limit/offset emulation adds doctrine_rownum to the result set).
98
     *
99
     * @param string $name
100
     * @return boolean
101
     */
102
    protected function _isIgnoredName($name)
103
    {
104
        return $name == 'DOCTRINE_ROWNUM';
105
    }
106
 
107
    /**
108
     * hydrateResultSet
109
     * parses the data returned by statement object
110
     *
111
     * This is method defines the core of Doctrine object population algorithm
112
     * hence this method strives to be as fast as possible
113
     *
114
     * The key idea is the loop over the rowset only once doing all the needed operations
115
     * within this massive loop.
116
     *
117
     * @param mixed $stmt
118
     * @return mixed
119
     */
120
    abstract public function hydrateResultSet($stmt);
121
}