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

Source for file DB.php

Documentation is available at DB.php

  1. <?php
  2.  
  3. // +----------------------------------------------------------------------+
  4. // | PEAR :: DB_NestedSet_DB                                              |
  5. // +----------------------------------------------------------------------+
  6. // | Copyright (c) 1997-2003 The PHP Group                                |
  7. // +----------------------------------------------------------------------+
  8. // | This source file is subject to version 2.0 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: Daniel Khan <dk@webcluster.at>                              |
  17. // +----------------------------------------------------------------------+
  18.  
  19. // $Id: DB.php 244556 2007-10-21 20:17:27Z datenpunk $
  20.  
  21. require_once 'DB.php';
  22. // {{{ DB_NestedSet_DB:: class
  23. /**
  24.  * Wrapper class for PEAR::DB
  25.  *
  26.  * @author Daniel Khan <dk@webcluster.at>
  27.  * @package DB_NestedSet
  28.  * @version $Revision: 244556 $
  29.  * @access public
  30.  */
  31. // }}}
  32. class DB_NestedSet_DB extends DB_NestedSet {
  33.     // {{{ properties
  34.     /**
  35.      *
  36.      * @var object Db object
  37.      */
  38.     var $db;
  39.     // }}}
  40.     // {{{ constructor
  41.     /**
  42.      * Constructor
  43.      *
  44.      * @param mixed $dsn DSN as PEAR dsn URI or dsn Array
  45.      * @param array $params Database column fields which should be returned
  46.      */
  47.     function DB_NestedSet_DB($dsn$params = array()) {
  48.         $this->_debugMessage('DB_NestedSet_DB($dsn, $params = array())');
  49.         $this->DB_NestedSet($params);
  50.         $this->db = $this->_db_Connect($dsn);
  51.         if ($this->_isDBError($this->db)) {
  52.             return false;
  53.         }
  54.         $this->db->setFetchMode(DB_FETCHMODE_ASSOC);
  55.     }
  56.     // }}}
  57.     // {{{ destructor
  58.     /**
  59.      * Destructor
  60.      */
  61.     function _DB_NestedSet_DB({
  62.         $this->_debugMessage('_DB_NestedSet_DB()');
  63.         $this->_DB_NestedSet();
  64.         $this->_db_Disconnect();
  65.     }
  66.     // }}}
  67.     // {{{ _db_Connect()
  68.     /**
  69.      * Connects to the db
  70.      *
  71.      * @return object DB The database object
  72.      * @access private
  73.      */
  74.     function _db_Connect($dsn{
  75.         $this->_debugMessage('_db_Connect($dsn)');
  76.         if (DB::isConnection($this->db)) {
  77.             return $this->db;
  78.         }
  79.         if (DB::isConnection($dsn)) {
  80.             return $dsn;
  81.         }
  82.         $db DB::connect($dsn);
  83.         $this->_testFatalAbort($db__FILE____LINE__);
  84.         return $db;
  85.     }
  86.     // }}}
  87.     // {{{ _numRows()
  88.     function _numRows($res{
  89.         return $res->numRows();
  90.     }
  91.     // }}}
  92.     // {{{ _isDBError()
  93.     function _isDBError($err{
  94.         if (!DB::isError($err)) {
  95.             return false;
  96.         }
  97.         return true;
  98.     }
  99.     // }}}
  100.     // {{{ _query()
  101.     function _query($sql{
  102.         return $this->db->query($sql);
  103.     }
  104.     // }}}
  105.     // {{{ _quote()
  106.     function _quote($str{
  107.         if (method_exists($this->db'quoteSmart')) {
  108.             return $this->db->quoteSmart($str);
  109.         }
  110.         return $this->db->quote($str);
  111.     }
  112.     // }}}
  113.     // {{{ _quoteIdentifier()
  114.     function _quoteIdentifier($str{
  115.         if (method_exists($this->db'quoteIdentifier')) {
  116.             return $this->db->quoteIdentifier($str);
  117.         }
  118.         return $this->_quote($str);
  119.     }
  120.     // }}}
  121.     // {{{ _dropSequence()
  122.     function _dropSequence($sequence{
  123.         return $this->db->dropSequence($this->sequence_table);
  124.     }
  125.     // }}}
  126.     // {{{ _nextId()
  127.     function _nextId($sequence{
  128.         return $this->db->nextId($sequence);
  129.     }
  130.     // }}}
  131.  
  132.     // {{{ _getOne()
  133.  
  134.     /**
  135.      * @param string $sql SQL query
  136.      * @return mixed 
  137.      * @access private
  138.      */
  139.     function _getOne($sql)
  140.     {
  141.         return $this->db->getOne($sql);
  142.     }
  143.  
  144.     // }}}
  145.  
  146.     // {{{ _getAll()
  147.     function _getAll($sql{
  148.         return $this->db->getAll($sqlnullDB_FETCHMODE_ASSOC);
  149.     }
  150.     // }}}
  151.     // {{{ _db_Disconnect()
  152.     /**
  153.      * Disconnects from db
  154.      *
  155.      * @return void 
  156.      * @access private
  157.      */
  158.     function _db_Disconnect({
  159.         $this->_debugMessage('_db_Disconnect()');
  160.         if (is_object($this->db)) {
  161.             @$this->db->disconnect();
  162.         }
  163.  
  164.         return true;
  165.     }
  166.     // }}}
  167. }
  168. ?>

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