[ Index ] |
|
Code source de CMS made simple 1.0.5 |
1 <?php 2 // Generic Pear Module 3 // This module contains alternative Pear commands. 4 5 eval('class pear_EXTENDER extends ' . $last_module . '_ADOConnection { }'); 6 7 class pear_ADOConnection extends pear_EXTENDER 8 { 9 /** 10 * Set how select queries will retrieve data. 11 * Usage: $oldmode = $db->SetFetchMode($mode) 12 * 13 * @param mode The fetchmode ADODB_FETCH_ASSOC or ADODB_FETCH_NUM 14 * @returns The previous fetch mode 15 */ 16 function SetFetchMode($mode) 17 { 18 GLOBAL $ADODB_FETCH_MODE; 19 $old = $ADODB_FETCH_MODE; 20 $ADODB_FETCH_MODE = $mode; 21 return $old; 22 } 23 24 /** 25 * Returns the last record id of an inserted item 26 * Usage: $db->GetCol($sql); 27 * 28 * @access public 29 */ 30 31 function GetCol($sql, $inputarr = false, $trim = false) 32 { 33 $data = false; 34 $result =& $this->do_query($sql, -1, -1, $inputarr); 35 if ($result) { 36 $data = array(); 37 while (!$result->EOF) { 38 $data[] = ($trim) ? trim(reset($result->fields)) : reset($result->fields); 39 $result->MoveNext(); 40 } 41 $result->Close(); 42 } 43 return $data; 44 } 45 46 /** 47 * Return first element of first row of sql statement. Recordset is disposed 48 * for you. 49 * 50 * Usage: $db->GetOne($sql); 51 * @access public 52 */ 53 54 function &GetOne($sql, $inputarr = false) 55 { 56 $data =& $this->GetRow($sql, $inputarr, true); 57 return $data; 58 } 59 60 /** 61 * Return one row of sql statement. Recordset is disposed for you. 62 * 63 * Usage: $db->GetRow($sql); 64 * @access public 65 */ 66 67 function &GetRow($sql, $inputarr = false, $getone = false) 68 { 69 $data = false; 70 $result =& $this->do_query($sql, -1, -1, $inputarr); 71 if ($result) { 72 if ($getone) 73 { 74 if (!$result->EOF) $data = reset($result->fields); 75 } 76 else 77 { 78 if (!$result->EOF) $data = $result->fields; 79 else $data = array(); 80 } 81 $result->Close(); 82 } 83 return $data; 84 } 85 86 /** 87 * PEAR DB Compat - do not use internally 88 */ 89 function &Query($sql, $inputarr = false) 90 { 91 $rs =& $this->do_query($sql, -1, -1, $inputarr); 92 return $rs; 93 } 94 95 /** 96 * PEAR DB Compat - do not use internally 97 */ 98 function &LimitQuery($sql, $offset, $nrows, $inputarr = false) 99 { 100 $rs =& $this->do_query($sql, $nrows, $offset, $inputarr); 101 return $rs; 102 } 103 104 /** 105 * PEAR DB Compat - do not use internally 106 */ 107 function Disconnect() 108 { 109 return $this->Close(); 110 } 111 112 /** 113 * PEAR DB Compat - do not use internally 114 */ 115 function ErrorNative() 116 { 117 return $this->ErrorNo(); 118 } 119 120 /** 121 * PEAR DB Compat - do not use internally 122 */ 123 function Quote($string) 124 { 125 return $this->qstr($string, false); 126 } 127 128 } 129 130 eval('class pear_resultset_EXTENDER extends ' . $last_module . '_ResultSet { }'); 131 132 class pear_ResultSet extends pear_resultset_EXTENDER 133 { 134 /** 135 * PEAR DB Compatable Command 136 */ 137 function Free() 138 { 139 return $this->Close(); 140 } 141 142 /** 143 * PEAR DB Compatable Command 144 */ 145 function NumRows() 146 { 147 return $this->_numOfRows; 148 } 149 150 /** 151 * PEAR DB Compatable Command 152 */ 153 function NumCols() 154 { 155 return $this->_numOfFields; 156 } 157 158 /** 159 * Fetch a row, returning false if no more rows. 160 * PEAR DB Compatable Command 161 * 162 * @return false or array containing the current record 163 */ 164 function FetchRow() 165 { 166 if ($this->EOF) { 167 $false = false; 168 return $false; 169 } 170 $arr = $this->fields; 171 $this->_currentRow++; 172 if (!$this->_fetch()) $this->EOF = true; 173 return $arr; 174 } 175 176 /** 177 * Fetch a row, returning PEAR_Error if no more rows. 178 * PEAR DB Compatable Command 179 * 180 */ 181 function FetchInto(&$arr) 182 { 183 $false = false; 184 $true = 1; 185 if ($this->EOF) return $false; 186 $arr = $this->fields; 187 $this->MoveNext(); 188 return $true; 189 } 190 191 } 192 ?>
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
Généré le : Tue Apr 3 18:50:37 2007 | par Balluche grâce à PHPXref 0.7 |