Subversion-Projekte lars-tiefland.php_share

Revision

Details | Letzte Änderung | Log anzeigen | RSS feed

Revision Autor Zeilennr. Zeile
1 lars 1
<?php
2
/* vim: set expandtab tabstop=4 shiftwidth=4: */
3
// +----------------------------------------------------------------------+
4
// | PHP Version 4                                                        |
5
// +----------------------------------------------------------------------+
6
// | Copyright (c) 1997-2003 The PHP Group                                |
7
// +----------------------------------------------------------------------+
8
// | This source file is subject to version 2.02 of the PHP license,      |
9
// | that is bundled with this package in the file LICENSE, and is        |
10
// | available at through the world-wide-web at                           |
11
// | http://www.php.net/license/2_02.txt.                                 |
12
// | If you did not receive a copy of the PHP license and are unable to   |
13
// | obtain it through the world-wide-web, please send a note to          |
14
// | license@php.net so we can mail you a copy immediately.               |
15
// +----------------------------------------------------------------------+
16
// | Authors:                                                             |
17
// +----------------------------------------------------------------------+
18
//
19
//  $Id: MDBnested.php,v 1.3.2.2 2009/03/12 17:19:48 dufuz Exp $
20
 
21
require_once 'Tree/Dynamic/MDBnested.php';
22
 
23
/**
24
*
25
*
26
*   @access     public
27
*   @author
28
*   @package    Tree
29
*/
30
class Tree_Memory_MDBnested extends Tree_Dynamic_MDBnested
31
{
32
 
33
    /**
34
     * retreive all the data from the db and prepare the data so the structure
35
     * can be built in the parent class
36
     *
37
     * @version 2002/04/20
38
     * @access  public
39
     * @author  Wolfram Kriesing <wolfram@kriesing.de>
40
     * @param   array   the result of a query which retreives (all)
41
     *                  the tree data from a DB
42
     * @return  array   the result
43
     */
44
    function setup($res = null)
45
    {
46
        if ($res == null) {
47
            //
48
            $whereAddOn = '';
49
            if ($this->options['whereAddOn']) {
50
                $whereAddOn = 'WHERE '.$this->getOption('whereAddOn');
51
            }
52
 
53
            //
54
            $orderBy = 'left';
55
            if ($order=$this->getOption('order')) {
56
                $orderBy = $order;
57
            }
58
 
59
            // build the query this way, that the root, which has no parent
60
            // (parentId=0) is first
61
            $query = sprintf('SELECT * FROM %s %s ORDER BY %s',
62
                                $this->table,
63
                                $whereAddOn,
64
                                // sort by the left-column, so we have the data
65
                                //sorted as it is supposed to be :-)
66
                                $this->_getColName($orderBy)
67
                                );
68
            if (MDB::isError($res = $this->dbh->getAll($query))) {
69
                return $this->_throwError($res->getMessage(), __LINE__);
70
            }
71
        }
72
 
73
        return $this->_prepareResults($res);
74
    }
75
 
76
}