Tree
[ class tree: Tree ] [ index: Tree ] [ all elements ]

Source for file MDBnested.php

Documentation is available at MDBnested.php

  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 320703 2011-12-08 22:08:40Z danielc $
  20.  
  21. require_once 'Tree/Dynamic/MDBnested.php';
  22.  
  23. /**
  24. *
  25. *
  26. *   @access     public
  27. *   @author
  28. *   @package    Tree
  29. */
  30. {
  31.  
  32.     /**
  33.      * retreive all the data from the db and prepare the data so the structure
  34.      * can be built in the parent class
  35.      *
  36.      * @version 2002/04/20
  37.      * @access  public
  38.      * @author  Wolfram Kriesing <wolfram@kriesing.de>
  39.      * @param   array   the result of a query which retreives (all)
  40.      *                   the tree data from a DB
  41.      * @return  array   the result
  42.      */
  43.     function setup($res = null)
  44.     {
  45.         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
  59.             // (parentId=0) is first
  60.             $query sprintf('SELECT * FROM %s %s ORDER BY %s',
  61.                                 $this->table,
  62.                                 $whereAddOn,
  63.                                 // sort by the left-column, so we have the data
  64.                                 //sorted as it is supposed to be :-)
  65.                                 $this->_getColName($orderBy)
  66.                                 );
  67.             if (MDB::isError($res $this->dbh->getAll($query))) {
  68.                 return $this->_throwError($res->getMessage()__LINE__);
  69.             }
  70.         }
  71.  
  72.         return $this->_prepareResults($res);
  73.     }
  74.  
  75. }

Documentation generated on Mon, 11 Mar 2019 15:47:06 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.