Make WordPress Core

Changeset 4549


Ignore:
Timestamp:
11/30/2006 01:44:33 AM (20 years ago)
Author:
ryan
Message:

Inline docs for wpdb. Props masquerade and davidhouse. #2474

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-includes/wp-db.php

    r4502 r4549  
    3737        var $postmeta;
    3838
    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         */
    4246        function wpdb($dbuser, $dbpassword, $dbname, $dbhost) {
    4347                $this->dbh = @mysql_connect($dbhost, $dbuser, $dbpassword);
    … …  
    5862        }
    5963
    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         */
    6368        function select($db) {
    6469                if (!@mysql_select_db($db, $this->dbh)) {
    … …  
    7479        }
    7580
    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         */
    7987        function escape($string) {
    8088                return addslashes( $string ); // Disable rest for now, causing problems
    … …  
    148156                $this->result = @mysql_query($query, $this->dbh);
    149157                ++$this->num_queries;
    150 
     158       
    151159                if (SAVEQUERIES)
    152160                        $this->queries[] = array( $query, $this->timer_stop() );
    … …  
    190198        }
    191199
    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         */
    195207        function get_var($query=null, $x = 0, $y = 0) {
    196208                $this->func_call = "\$db->get_var(\"$query\",$x,$y)";
    … …  
    207219        }
    208220
    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         */
    212228        function get_row($query = null, $output = OBJECT, $y = 0) {
    213229                $this->func_call = "\$db->get_row(\"$query\",$output,$y)";
    … …  
    229245        }
    230246
    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         */
    235253        function get_col($query = null , $x = 0) {
    236254                if ( $query )
    … …  
    244262        }
    245263
    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         */
    249270        function get_results($query = null, $output = OBJECT) {
    250271                $this->func_call = "\$db->get_results(\"$query\", $output)";
    … …  
    273294        }
    274295
    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         */
    280302        function get_col_info($info_type = 'name', $col_offset = -1) {
    281303                if ( $this->col_info ) {
    … …  
    293315        }
    294316
     317        /**
     318         * Starts the timer, for debugging purposes
     319         */
    295320        function timer_start() {
    296321                $mtime = microtime();
    … …  
    300325        }
    301326
    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() {
    303332                $mtime = microtime();
    304333                $mtime = explode(' ', $mtime);
    … …  
    308337        }
    309338
     339        /**
     340         * Wraps fatal errors in a nice header and footer and dies.
     341         * @param string $message
     342         */
    310343        function bail($message) { // Just wraps errors in a nice header and footer
    311344                if ( !$this->show_errors )
Note: See TracChangeset for help on using the changeset viewer.