[ Index ] |
|
Code source de SPIP Agora 1.4 |
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.17 2004/07/29 11:31:04 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.17 $ 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 129 // {{{ _getOne() 130 131 /** 132 * @param string $sql SQL query 133 * @return mixed 134 * @access private 135 */ 136 function _getOne($sql) 137 { 138 return $this->db->getOne($sql); 139 } 140 141 // }}} 142 143 // {{{ _getAll() 144 function _getAll($sql) { 145 return $this->db->getAll($sql, null, DB_FETCHMODE_ASSOC); 146 } 147 // }}} 148 // {{{ _db_Disconnect() 149 /** 150 * Disconnects from db 151 * 152 * @return void 153 * @access private 154 */ 155 function _db_Disconnect() { 156 $this->_debugMessage('_db_Disconnect()'); 157 if (is_object($this->db)) { 158 @$this->db->disconnect(); 159 } 160 161 return true; 162 } 163 // }}} 164 } 165 ?>
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
Généré le : Sat Feb 24 14:40:03 2007 | par Balluche grâce à PHPXref 0.7 |