/[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.2 - (hide annotations)
Wed Jul 7 02:49:21 2004 UTC (20 years, 1 month ago) by joko
Branch: MAIN
CVS Tags: HEAD
Changes since 1.1: +28 -27 lines
updated to Tree-0.2.4

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

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