Ticket #913: getAttribute.patch
| File getAttribute.patch, 4.7 kB (added by foxmask, 16 months ago) |
|---|
-
db/jDbConnection.class.php
30 30 const ATTR_CURSOR = 10; 31 31 const CURSOR_FWDONLY = 0; 32 32 const CURSOR_SCROLL = 1; 33 33 const ATTR_CLIENT_VERSION = null; 34 const ATTR_SERVER_INFO = null; 35 const ATTR_SERVER_VERSION = null; 36 34 37 /** 35 38 * profile properties used by the connector 36 39 * @var array … … 229 232 abstract public function lastInsertId($fromSequence=''); 230 233 231 234 /** 232 * Not implemented235 * return the value of the Attribute of the current Connection 233 236 * @param integer $id the attribut id 234 237 * @return string the attribute value 235 238 */ 236 public function getAttribute($id){ return '';}239 abstract public function getAttribute($id); 237 240 238 241 /** 239 * Not implemented242 * set the value of the Attribute of the current Connection 240 243 * @param integer $id the attribut id 241 244 * @param string $value the attribute value 242 245 */ 243 public function setAttribute($id, $value){ } 246 public function setAttribute($id, $value) { 247 define ("$id", $value); 248 } 244 249 245 250 /** 246 251 * -
plugins/db/mysql/mysql.dbconnection.php
32 32 throw new jException('jelix~db.error.nofunction','mysql'); 33 33 } 34 34 parent::__construct($profile); 35 $this->_setAttributes(); 35 36 } 36 37 37 38 /** … … 90 91 && isset($this->_charsets[$GLOBALS['gJConfig']->charset])){ 91 92 mysql_query("SET NAMES '".$this->_charsets[$GLOBALS['gJConfig']->charset]."'", $cnx); 92 93 } 94 95 93 96 return $cnx; 94 97 }else{ 95 98 throw new jException('jelix~db.error.connection',$this->profile['host']); … … 156 159 return mysql_real_escape_string($text, $this->_connection ); 157 160 } 158 161 162 /** 163 * return the value of the given Attribute 164 * @param the Attribute to get 165 * @return string the value of the Attribute 166 */ 167 public function getAttribute($id) { 168 return constant("ATTR_$id"); 169 } 170 171 protected function _setAttributes() { 172 $this->setAttribute("ATTR_CLIENT_VERSION",mysql_get_client_info()); 173 $this->setAttribute("ATTR_SERVER_INFO",mysql_get_host_info($this->_connect())); 174 $this->setAttribute("ATTR_SERVER_VERSION",mysql_get_server_info($this->_connect())); 175 } 159 176 } 160 177 -
plugins/db/pgsql/pgsql.dbconnection.php
39 39 { 40 40 $this->setAutoCommit(true); 41 41 } 42 $this->_setAttributes(); 42 43 } 43 44 44 45 /** … … 191 192 protected function _quote($text){ 192 193 return pg_escape_string($text); 193 194 } 195 196 197 /** 198 * return the value of the given Attribute 199 * @param the Attribute to get 200 * @return string the value of the Attribute 201 */ 202 public function getAttribute($id) { 203 return constant("ATTR_$id"); 204 } 205 206 protected function _setAttributes() { 207 $v = pg_version($this->_connect()); 208 $this->setAttribute("ATTR_CLIENT_VERSION",array_key_exists('client') ? $v['client'] : null); 209 $this->setAttribute("ATTR_SERVER_INFO",null); 210 $this->setAttribute("ATTR_SERVER_VERSION", pg_parameter_status($this->_connect(),'server_info')); 211 } 212 194 213 } 195 214 -
plugins/db/sqlite/sqlite.dbconnection.php
21 21 throw new jException('jelix~db.error.nofunction','sqlite'); 22 22 } 23 23 parent::__construct($profile); 24 $this->_setAttributes(); 24 25 } 25 26 26 27 /** … … 115 116 return sqlite_escape_string($text); 116 117 } 117 118 119 120 /** 121 * return the value of the given Attribute 122 * @param the Attribute to get 123 * @return string the value of the Attribute 124 */ 125 public function getAttribute($id) { 126 return constant("ATTR_$id"); 127 } 128 129 protected function _setAttributes() { 130 $this->setAttribute("ATTR_CLIENT_VERSION",sqlite_libversion(); 131 $this->setAttribute("ATTR_SERVER_INFO",null); 132 $this->setAttribute("ATTR_SERVER_VERSION", null); 133 } 134 118 135 } 119 136
