/[cvs]/nfo/php/libs/net.php.pear/Tree/Memory/DBnested.php
ViewVC logotype

Annotation of /nfo/php/libs/net.php.pear/Tree/Memory/DBnested.php

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.1 - (hide annotations)
Thu Feb 27 16:49:59 2003 UTC (21 years, 6 months ago) by joko
Branch: MAIN
+ initial commit, from PEAR

1 joko 1.1 <?php
2     //
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: DBnested.php,v 1.6 2003/01/04 11:56:28 mj Exp
20     // $Id: DBnested.php,v 1.6 2003/01/04 11:56:28 mj Exp $
21    
22     require_once('Tree/Dynamic/DBnested.php');
23    
24     /**
25     *
26     *
27     * @access public
28     * @author
29     * @package Tree
30     */
31     class Tree_Memory_DBnested extends Tree_Dynamic_DBnested
32     {
33    
34     /**
35     * retreive all the data from the db and prepare the data so the structure can
36     * be built in the parent class
37     *
38     * @version 2002/04/20
39     * @access public
40     * @author Wolfram Kriesing <wolfram@kriesing.de>
41     * @return array the result
42     */
43     function setup()
44     {
45     //
46     $whereAddOn = '';
47     if( $this->options['whereAddOn'] )
48     {
49     $whereAddOn = 'WHERE '.$this->getOption('whereAddOn');
50     }
51    
52     //
53     $orderBy = 'left';
54     if( $order=$this->getOption('order') )
55     {
56     $orderBy = $order;
57     }
58    
59     // build the query this way, that the root, which has no parent (parentId=0) is first
60     $query = sprintf( 'SELECT * FROM %s %s ORDER BY %s',
61     $this->table,
62     $whereAddOn,
63     $this->_getColName($orderBy) // sort by the left-column, so we have the data sorted as it is supposed to be :-)
64     );
65     if( DB::isError( $res = $this->dbh->getAll( $query ) ) )
66     {
67     return $this->_throwError($res->getMessage(),__LINE__);
68     }
69    
70     return $this->_prepareResults( $res );
71     }
72    
73     }

MailToCvsAdmin">MailToCvsAdmin
ViewVC Help
Powered by ViewVC 1.1.26 RSS 2.0 feed