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

Source for file MDB.php

Documentation is available at MDB.php

  1. <?php
  2. //
  3. // +----------------------------------------------------------------------+
  4. // | PEAR :: DB_NestedSet_MDB                                             |
  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. // Thanks to Hans Lellelid for suggesting support for PEAR::MDB
  19. // and for his help in implementing this.
  20. //
  21. // $Id: MDB.php 164620 2004-07-29 11:31:04Z datenpunk $
  22. //
  23.  
  24. require_once 'MDB.php';
  25. // {{{ DB_NestedSet_MDB:: class
  26.  
  27. /**
  28. * Wrapper class for PEAR::MDB
  29. *
  30. @author       Daniel Khan <dk@webcluster.at>
  31. @package      DB_NestedSet
  32. @version      $Revision: 164620 $
  33. @access       public
  34. */
  35. // }}}
  36. class DB_NestedSet_MDB extends DB_NestedSet {
  37.     // {{{ properties
  38.  
  39.     /**
  40.     * @var object The MDB object
  41.     */
  42.     var $db;
  43.  
  44.     // }}}
  45.     // {{{ constructor
  46.  
  47.     /**
  48.     * Constructor
  49.     *
  50.     * @param mixed $dsn DSN as PEAR dsn URI or dsn Array
  51.     * @param array $params Database column fields which should be returned
  52.     *
  53.     */
  54.     function DB_NestedSet_MDB(&$dsn$params = array())
  55.     {
  56.         $this->_debugMessage('DB_NestedSet_MDB($dsn, $params = array())');
  57.         $this->DB_NestedSet($params);
  58.         $this->db =$this->_db_Connect($dsn);
  59.         $this->db->setFetchMode(MDB_FETCHMODE_ASSOC);
  60.     }
  61.  
  62.     // }}}
  63.     // {{{ destructor
  64.  
  65.     /**
  66.     * Destructor
  67.     */
  68.     function _DB_NestedSet_MDB()
  69.     {
  70.         $this->_debugMessage('_DB_NestedSet_MDB()');
  71.         $this->_DB_NestedSet();
  72.         $this->_db_Disconnect();
  73.     }
  74.  
  75.     // }}}
  76.     // {{{ _db_Connect()
  77.  
  78.     /**
  79.     * Connects to the db
  80.     *
  81.     * @return object DB The database object
  82.     * @access private
  83.     */
  84.     function &_db_Connect(&$dsn)
  85.     {
  86.         $this->_debugMessage('_db_Connect($dsn)');
  87.         if (is_object($this->db)) {
  88.             return $this->db;
  89.         }
  90.  
  91.         if (is_object($dsn)) {
  92.             return $dsn;
  93.         }
  94.  
  95.         $db =MDB::connect($dsn);
  96.         $this->_testFatalAbort($db__FILE____LINE__);
  97.  
  98.         return $db;
  99.     }
  100.  
  101.     // }}}
  102.     // {{{ _isDBError()
  103.  
  104.     function _isDBError($err)
  105.     {
  106.         if (!MDB::isError($err)) {
  107.             return false;
  108.         }
  109.         return true;
  110.     }
  111.  
  112.     // }}}
  113.  
  114.     // {{{ _query()
  115.     function _query($sql{
  116.       return $this->db->query($sql);
  117.     }
  118.  
  119.     // {{{ _nextId()
  120.  
  121.     function _nextId($sequence)
  122.     {
  123.         return $this->db->nextId($sequence);
  124.     }
  125.  
  126.     // }}}
  127.     // {{{ _dropSequence()
  128.  
  129.     function _dropSequence($sequence)
  130.     {
  131.         $this->db->loadManager();
  132.         return $this->db->dropSequence($sequence);
  133.     }
  134.  
  135.     // }}}
  136.     // {{{ _getOne()
  137.  
  138.     /**
  139.      * @param string $sql SQL query
  140.      * @return mixed 
  141.      * @access private
  142.      */
  143.     function _getOne($sql)
  144.     {
  145.         return $this->db->queryOne($sql);
  146.     }
  147.  
  148.     // }}}
  149.     // {{{ _getAll()
  150.  
  151.     function _getAll($sql)
  152.     {
  153.         return $this->db->queryAll($sqlnullMDB_FETCHMODE_ASSOC);
  154.     }
  155.  
  156.     // }}}
  157.     // {{{ _numRows()
  158.  
  159.     function _numRows($res)
  160.     {
  161.         return $this->db->numRows($res);
  162.     }
  163.  
  164.     // }}}
  165.     // {{{ _quote()
  166.  
  167.     function _quote($str)
  168.     {
  169.         return $this->db->getTextValue($str);
  170.     }
  171.  
  172.     // }}}
  173.     // {{{ _quoteIdentifier()
  174.     function _quoteIdentifier($str{
  175.  
  176.     // will work as soon as MDB supports this
  177.         if (method_exists($this->db'quoteIdentifier')) {
  178.             return $this->db->quoteIdentifier($str);
  179.         }
  180.         return $str;
  181.     }
  182.   // }}}
  183.     // {{{ _db_Disconnect()
  184.     /**
  185.     * Disconnects from db
  186.     *
  187.     * @return void 
  188.     * @access private
  189.     */
  190.     function _db_Disconnect()
  191.     {
  192.         $this->_debugMessage('_db_Disconnect()');
  193.         if (is_object($this->db)) {
  194.             @$this->db->disconnect();
  195.         }
  196.  
  197.         return true;
  198.     }
  199.  
  200.     // }}}
  201. }
  202.  
  203. ?>

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