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,v 1.16 2004/07/25 11:55:22 datenpunk Exp $
  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: 1.16 $
  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.         $this->db->setFetchMode(DB_FETCHMODE_ASSOC);
  52.     }
  53.     // }}}
  54.     // {{{ destructor
  55.     /**
  56.      * Destructor
  57.      */
  58.     function _DB_NestedSet_DB({
  59.         $this->_debugMessage('_DB_NestedSet_DB()');
  60.         $this->_DB_NestedSet();
  61.         $this->_db_Disconnect();
  62.     }
  63.     // }}}
  64.     // {{{ _db_Connect()
  65.     /**
  66.      * Connects to the db
  67.      *
  68.      * @return object DB The database object
  69.      * @access private
  70.      */
  71.     function _db_Connect($dsn{
  72.         $this->_debugMessage('_db_Connect($dsn)');
  73.         if (DB::isConnection($this->db)) {
  74.             return $this->db;
  75.         }
  76.         if (DB::isConnection($dsn)) {
  77.             return $dsn;
  78.         }
  79.         $db DB::connect($dsn);
  80.         $this->_testFatalAbort($db__FILE____LINE__);
  81.         return $db;
  82.     }
  83.     // }}}
  84.     // {{{ _numRows()
  85.     function _numRows($res{
  86.         return $res->numRows();
  87.     }
  88.     // }}}
  89.     // {{{ _isDBError()
  90.     function _isDBError($err{
  91.         if (!DB::isError($err)) {
  92.             return false;
  93.         }
  94.         return true;
  95.     }
  96.     // }}}
  97.     // {{{ _query()
  98.     function _query($sql{
  99.       return $this->db->query($sql);
  100.     }
  101.     // }}}
  102.     // {{{ _quote()
  103.     function _quote($str{
  104.         if (method_exists($this->db'quoteSmart')) {
  105.             return $this->db->quoteSmart($str);
  106.         }
  107.         return $this->db->quote($str);
  108.     }
  109.     // }}}
  110.     // {{{ _quoteIdentifier()
  111.     function _quoteIdentifier($str{
  112.         if (method_exists($this->db'quoteIdentifier')) {
  113.             return $this->db->quoteIdentifier($str);
  114.         }
  115.         return $this->_quote($str);
  116.     }
  117.     // }}}
  118.     // {{{ _dropSequence()
  119.     function _dropSequence($sequence{
  120.         return $this->db->dropSequence($this->sequence_table);
  121.     }
  122.     // }}}
  123.     // {{{ _nextId()
  124.     function _nextId($sequence{
  125.         return $this->db->nextId($sequence);
  126.     }
  127.     // }}}
  128.     // {{{ _getAll()
  129.     function _getAll($sql{
  130.         return $this->db->getAll($sqlnullDB_FETCHMODE_ASSOC);
  131.     }
  132.     // }}}
  133.     // {{{ _db_Disconnect()
  134.     /**
  135.      * Disconnects from db
  136.      *
  137.      * @return void 
  138.      * @access private
  139.      */
  140.     function _db_Disconnect({
  141.         $this->_debugMessage('_db_Disconnect()');
  142.         if (is_object($this->db)) {
  143.             @$this->db->disconnect();
  144.         }
  145.  
  146.         return true;
  147.     }
  148.     // }}}
  149. }
  150. ?>

Documentation generated on Mon, 11 Mar 2019 13:54:02 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.