Subversion Repositories Applications.papyrus

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
1173 jp_milcent 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.1 2006-12-14 15:04:29 jp_milcent Exp $
22
//
23
 
24
require_once 'MDB.php';
25
 
26
// {{{ DB_NestedSet_MDB:: class
27
 
28
/**
29
* Wrapper class for PEAR::MDB
30
*
31
* @author       Daniel Khan <dk@webcluster.at>
32
* @package      DB_NestedSet
33
* @version      $Revision: 1.1 $
34
* @access       public
35
*/
36
// }}}
37
class DB_NestedSet_MDB extends DB_NestedSet {
38
    // {{{ properties
39
 
40
    /**
41
    * @var object The MDB object
42
    */
43
    var $db;
44
 
45
    // }}}
46
    // {{{ constructor
47
 
48
    /**
49
    * Constructor
50
    *
51
    * @param mixed $dsn DSN as PEAR dsn URI or dsn Array
52
    * @param array $params Database column fields which should be returned
53
    *
54
    */
55
    function DB_NestedSet_MDB($dsn, $params = array())
56
    {
57
        $this->_debugMessage('DB_NestedSet_MDB($dsn, $params = array())');
58
        $this->DB_NestedSet($params);
59
        $this->db =& $this->_db_Connect($dsn);
60
        $this->db->setFetchMode(MDB_FETCHMODE_ASSOC);
61
    }
62
 
63
    // }}}
64
    // {{{ destructor
65
 
66
    /**
67
    * Destructor
68
    */
69
    function _DB_NestedSet_MDB()
70
    {
71
        $this->_debugMessage('_DB_NestedSet_MDB()');
72
        $this->_DB_NestedSet();
73
        $this->_db_Disconnect();
74
    }
75
 
76
    // }}}
77
    // {{{ _db_Connect()
78
 
79
    /**
80
    * Connects to the db
81
    *
82
    * @return object DB The database object
83
    * @access private
84
    */
85
    function &_db_Connect($dsn)
86
    {
87
        $this->_debugMessage('_db_Connect($dsn)');
88
        if (is_object($this->db)) {
89
            return $this->db;
90
        }
91
 
92
        $db =& MDB::connect($dsn);
93
        $this->_testFatalAbort($db, __FILE__, __LINE__);
94
 
95
        return $db;
96
    }
97
 
98
    // }}}
99
 
100
    function _isDBError($err) {
101
        if(!MDB::isError($err)) {
102
            return false;
103
        }
104
        return true;
105
    }
106
 
107
    function _numRows($res) {
108
        return $this->db->numRows($res);
109
    }
110
 
111
    function _quote($str) {
112
        return $this->db->getTextValue($str);
113
    }
114
 
115
    // {{{ _db_Disconnect()
116
 
117
    /**
118
    * Disconnects from db
119
    *
120
    * @return void
121
    * @access private
122
    */
123
    function _db_Disconnect()
124
    {
125
        $this->_debugMessage('_db_Disconnect()');
126
        if (is_object($this->db)) {
127
            @$this->db->disconnect();
128
        }
129
 
130
        return true;
131
    }
132
 
133
    // }}}
134
}
135
 
136
?>