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

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

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.1 by joko, Thu Feb 27 16:49:59 2003 UTC revision 1.2 by joko, Wed Jul 7 02:49:21 2004 UTC
# Line 16  Line 16 
16  // | Authors:                                                             |  // | Authors:                                                             |
17  // +----------------------------------------------------------------------+  // +----------------------------------------------------------------------+
18  //  //
 //  Id: DBnested.php,v 1.6 2003/01/04 11:56:28 mj Exp  
19  //  $Id$  //  $Id$
20    
21  require_once('Tree/Dynamic/DBnested.php');  require_once 'Tree/Dynamic/DBnested.php';
22    
23  /**  /**
24  *  *
# Line 38  class Tree_Memory_DBnested extends Tree_ Line 37  class Tree_Memory_DBnested extends Tree_
37      *   @version    2002/04/20      *   @version    2002/04/20
38      *   @access     public      *   @access     public
39      *   @author     Wolfram Kriesing <wolfram@kriesing.de>      *   @author     Wolfram Kriesing <wolfram@kriesing.de>
40        *   @param      array   the result of a query which retreives (all) the tree data from a DB
41      *   @return     array   the result      *   @return     array   the result
42      */      */
43      function setup()      function setup($res=null)
44      {      {
45          //          if ($res==null) {
46          $whereAddOn = '';              //
47          if( $this->options['whereAddOn'] )              $whereAddOn = '';
48          {              if ($this->options['whereAddOn']) {
49              $whereAddOn = 'WHERE '.$this->getOption('whereAddOn');                  $whereAddOn = 'WHERE '.$this->getOption('whereAddOn');
50          }              }
51    
52          //              //
53          $orderBy = 'left';              $orderBy = 'left';
54          if( $order=$this->getOption('order') )              if ($order=$this->getOption('order')) {
55          {                  $orderBy = $order;
56              $orderBy = $order;              }
57          }  
58                // build the query this way, that the root, which has no parent (parentId=0) is first
59          // build the query this way, that the root, which has no parent (parentId=0) is first              $query = sprintf(   'SELECT * FROM %s %s ORDER BY %s',
60          $query = sprintf(   'SELECT * FROM %s %s ORDER BY %s',                                  $this->table,
61                              $this->table,                                  $whereAddOn,
62                              $whereAddOn,                                  $this->_getColName($orderBy)  // sort by the left-column, so we have the data sorted as it is supposed to be :-)
63                              $this->_getColName($orderBy)  // sort by the left-column, so we have the data sorted as it is supposed to be :-)                                  );
64                              );              if (DB::isError( $res = $this->dbh->getAll($query))) {
65          if( DB::isError( $res = $this->dbh->getAll( $query ) ) )                  return $this->_throwError($res->getMessage(),__LINE__);
66          {              }
             return $this->_throwError($res->getMessage(),__LINE__);  
67          }          }
68    
69          return $this->_prepareResults( $res );          return $this->_prepareResults( $res );
70      }      }
71    
72  }  }
73    
74    ?>

Legend:
Removed from v.1.1  
changed lines
  Added in v.1.2

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