Changeset 4549
- Timestamp:
- 11/30/2006 01:44:33 AM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-includes/wp-db.php
r4502 r4549 37 37 var $postmeta; 38 38 39 // ================================================================== 40 // DB Constructor - connects to the server and selects a database 41 39 /** 40 * Connects to the database server and selects a database 41 * @param string $dbuser 42 * @param string $dbpassword 43 * @param string $dbname 44 * @param string $dbhost 45 */ 42 46 function wpdb($dbuser, $dbpassword, $dbname, $dbhost) { 43 47 $this->dbh = @mysql_connect($dbhost, $dbuser, $dbpassword); … … 58 62 } 59 63 60 // ================================================================== 61 // Select a DB (if another one needs to be selected) 62 64 /** 65 * Selects a database using the current class's $this->dbh 66 * @param string $db name 67 */ 63 68 function select($db) { 64 69 if (!@mysql_select_db($db, $this->dbh)) { … … 74 79 } 75 80 76 // ==================================================================== 77 // Format a string correctly for safe insert under all PHP conditions 78 81 /** 82 * Escapes content for insertion into the database, for security 83 * 84 * @param string $string 85 * @return string query safe string 86 */ 79 87 function escape($string) { 80 88 return addslashes( $string ); // Disable rest for now, causing problems … … 148 156 $this->result = @mysql_query($query, $this->dbh); 149 157 ++$this->num_queries; 150 158 151 159 if (SAVEQUERIES) 152 160 $this->queries[] = array( $query, $this->timer_stop() ); … … 190 198 } 191 199 192 // ================================================================== 193 // Get one variable from the DB - see docs for more detail 194 200 /** 201 * Get one variable from the database 202 * @param string $query (can be null as well, for caching, see codex) 203 * @param int $x = 0 row num to return 204 * @param int $y = 0 col num to return 205 * @return mixed results 206 */ 195 207 function get_var($query=null, $x = 0, $y = 0) { 196 208 $this->func_call = "\$db->get_var(\"$query\",$x,$y)"; … … 207 219 } 208 220 209 // ================================================================== 210 // Get one row from the DB - see docs for more detail 211 221 /** 222 * Get one row from the database 223 * @param string $query 224 * @param string $output ARRAY_A | ARRAY_N | OBJECT 225 * @param int $y row num to return 226 * @return mixed results 227 */ 212 228 function get_row($query = null, $output = OBJECT, $y = 0) { 213 229 $this->func_call = "\$db->get_row(\"$query\",$output,$y)"; … … 229 245 } 230 246 231 // ================================================================== 232 // Function to get 1 column from the cached result set based in X index 233 // se docs for usage and info 234 247 /** 248 * Gets one column from the database 249 * @param string $query (can be null as well, for caching, see codex) 250 * @param int $x col num to return 251 * @return array results 252 */ 235 253 function get_col($query = null , $x = 0) { 236 254 if ( $query ) … … 244 262 } 245 263 246 // ================================================================== 247 // Return the the query as a result set - see docs for more details 248 264 /** 265 * Return an entire result set from the database 266 * @param string $query (can also be null to pull from the cache) 267 * @param string $output ARRAY_A | ARRAY_N | OBJECT 268 * @return mixed results 269 */ 249 270 function get_results($query = null, $output = OBJECT) { 250 271 $this->func_call = "\$db->get_results(\"$query\", $output)"; … … 273 294 } 274 295 275 276 // ================================================================== 277 // Function to get column meta data info pertaining to the last query 278 // see docs for more info and usage 279 296 /** 297 * Grabs column metadata from the last query 298 * @param string $info_type one of name, table, def, max_length, not_null, primary_key, multiple_key, unique_key, numeric, blob, type, unsigned, zerofill 299 * @param int $col_offset 0: col name. 1: which table the col's in. 2: col's max length. 3: if the col is numeric. 4: col's type 300 * @return mixed results 301 */ 280 302 function get_col_info($info_type = 'name', $col_offset = -1) { 281 303 if ( $this->col_info ) { … … 293 315 } 294 316 317 /** 318 * Starts the timer, for debugging purposes 319 */ 295 320 function timer_start() { 296 321 $mtime = microtime(); … … 300 325 } 301 326 302 function timer_stop($precision = 3) { 327 /** 328 * Stops the debugging timer 329 * @return int total time spent on the query, in milliseconds 330 */ 331 function timer_stop() { 303 332 $mtime = microtime(); 304 333 $mtime = explode(' ', $mtime); … … 308 337 } 309 338 339 /** 340 * Wraps fatal errors in a nice header and footer and dies. 341 * @param string $message 342 */ 310 343 function bail($message) { // Just wraps errors in a nice header and footer 311 344 if ( !$this->show_errors )
Note: See TracChangeset
for help on using the changeset viewer.