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,v 1.15 2004/07/25 11:55:22 datenpunk Exp $
  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: 1.15 $
  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.     // {{{ _getAll()
  137.  
  138.     function _getAll($sql)
  139.     {
  140.         return $this->db->queryAll($sqlnullMDB_FETCHMODE_ASSOC);
  141.     }
  142.  
  143.     // }}}
  144.     // {{{ _numRows()
  145.  
  146.     function _numRows($res)
  147.     {
  148.         return $this->db->numRows($res);
  149.     }
  150.  
  151.     // }}}
  152.     // {{{ _quote()
  153.  
  154.     function _quote($str)
  155.     {
  156.         return $this->db->getTextValue($str);
  157.     }
  158.  
  159.     // }}}
  160.     // {{{ _quoteIdentifier()
  161.     function _quoteIdentifier($str{
  162.  
  163.     // will work as soon as MDB supports this
  164.         if (method_exists($this->db'quoteIdentifier')) {
  165.             return $this->db->quoteIdentifier($str);
  166.         }
  167.         return $str;
  168.     }
  169.   // }}}
  170.     // {{{ _db_Disconnect()
  171.     /**
  172.     * Disconnects from db
  173.     *
  174.     * @return void 
  175.     * @access private
  176.     */
  177.     function _db_Disconnect()
  178.     {
  179.         $this->_debugMessage('_db_Disconnect()');
  180.         if (is_object($this->db)) {
  181.             @$this->db->disconnect();
  182.         }
  183.  
  184.         return true;
  185.     }
  186.  
  187.     // }}}
  188. }
  189.  
  190. ?>

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