Subversion Repositories Applications.papyrus

Rev

Rev 1688 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
1173 jp_milcent 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.1 2006-12-14 15:04:29 jp_milcent Exp $
20
//
21
 
22
require_once 'DB.php';
23
 
24
// {{{ DB_NestedSet_DB:: class
25
 
26
/**
27
* Wrapper class for PEAR::DB
28
*
29
* @author       Daniel Khan <dk@webcluster.at>
30
* @package      DB_NestedSet
31
* @version      $Revision: 1.1 $
32
* @access       public
33
*/
34
 
35
// }}}
36
class DB_NestedSet_DB extends DB_NestedSet {
37
    // {{{ properties
38
 
39
    /**
40
    * @var object Db 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_DB($dsn, $params = array())
55
    {
56
        $this->_debugMessage('DB_NestedSet_DB($dsn, $params = array())');
57
        $this->DB_NestedSet($params);
58
        $this->db =& $this->_db_Connect($dsn);
59
        $this->db->setFetchMode(DB_FETCHMODE_ASSOC);
60
    }
61
 
62
    // }}}
63
    // {{{ destructor
64
 
65
    /**
66
    * Destructor
67
    */
68
    function _DB_NestedSet_DB()
69
    {
70
        $this->_debugMessage('_DB_NestedSet_DB()');
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
        $db =& DB::connect($dsn);
92
        $this->_testFatalAbort($db, __FILE__, __LINE__);
93
        return $db;
94
    }
95
 
96
    // }}}
97
 
98
 
99
    function _numRows($res) {
100
        return $res->numRows();
101
    }
102
 
103
    function _isDBError($err) {
104
        if(!DB::isError($err)) {
105
            return false;
106
        }
107
        return true;
108
    }
109
 
110
    function _quote($str) {
111
        return $this->db->quote($str);
112
    }
113
 
114
    // {{{ _db_Disconnect()
115
 
116
    /**
117
    * Disconnects from db
118
    *
119
    * @return void
120
    * @access private
121
    */
122
    function _db_Disconnect()
123
    {
124
        $this->_debugMessage('_db_Disconnect()');
125
        if (is_object($this->db)) {
126
            @$this->db->disconnect();
127
        }
128
 
129
        return true;
130
    }
131
 
132
    // }}}
133
}
134
 
135
?>