WordPress.org

Make WordPress Core

Changeset 14058


Ignore:
Timestamp:
04/10/10 12:39:25 (5 years ago)
Author:
nacin
Message:

Some wpdb cleanups.

File:
1 edited

Legend:

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

    r13949 r14058  
    2323 * @since 2.5.0 
    2424 */ 
    25 define( 'OBJECT_K', 'OBJECT_K', false ); 
     25define( 'OBJECT_K', 'OBJECT_K' ); 
    2626 
    2727/** 
    2828 * @since 0.71 
    2929 */ 
    30 define( 'ARRAY_A', 'ARRAY_A', false ); 
     30define( 'ARRAY_A', 'ARRAY_A' ); 
    3131 
    3232/** 
    3333 * @since 0.71 
    3434 */ 
    35 define( 'ARRAY_N', 'ARRAY_N', false ); 
     35define( 'ARRAY_N', 'ARRAY_N' ); 
    3636 
    3737/** 
     
    579579                return $old_prefix; 
    580580 
    581             $this->prefix = $this->get_blog_prefix( $this->blogid ); 
     581            $this->prefix = $this->get_blog_prefix(); 
    582582 
    583583            foreach ( $this->tables( 'blog' ) as $table => $prefixed_table ) 
     
    606606        $this->blogid = $blog_id; 
    607607 
    608         $this->prefix = $this->get_blog_prefix( $this->blogid ); 
     608        $this->prefix = $this->get_blog_prefix(); 
    609609 
    610610        foreach ( $this->tables( 'blog' ) as $table => $prefixed_table ) 
     
    625625     * @return string Blog prefix. 
    626626     */ 
    627     function get_blog_prefix( $blog_id = -1 ) { 
     627    function get_blog_prefix( $blog_id = null ) { 
    628628        if ( is_multisite() ) { 
    629             if ( $blog_id < 0 ) 
     629            if ( null === $blog_id ) 
    630630                $blog_id = $this->blogid; 
    631631            if ( defined( 'MULTISITE' ) && ( 0 == $blog_id || 1 == $blog_id ) ) 
     
    838838 
    839839    /** 
    840      * Prepares a SQL query for safe execution.  Uses sprintf()-like syntax. 
     840     * Prepares a SQL query for safe execution. Uses sprintf()-like syntax. 
    841841     * 
    842842     * The following directives can be used in the query format string: 
     
    845845     *   %% (literal percentage sign - no argument needed) 
    846846     * 
    847      * Both %d and %s are to be left unquoted in the query string and 
    848      * they need an argument passed for them. Literals (%) as parts of 
    849      * the query must be properly written as %%. 
     847     * Both %d and %s are to be left unquoted in the query string and they need an argument passed for them. 
     848     * Literals (%) as parts of the query must be properly written as %%. 
    850849     * 
    851850     * This function only supports a small subset of the sprintf syntax; it only supports %d (decimal number), %s (string). 
     
    13561355        $new_array = array(); 
    13571356        // Extract the column values 
    1358         for ( $i=0; $i < count( $this->last_result ); $i++ ) { 
     1357        for ( $i = 0, $j = count( $this->last_result ); $i < $j; $i++ ) { 
    13591358            $new_array[$i] = $this->get_var( null, $x, $i ); 
    13601359        } 
     
    13921391            foreach ( $this->last_result as $row ) { 
    13931392                $key = array_shift( get_object_vars( $row ) ); 
    1394                 if ( !isset( $new_array[ $key ] ) ) 
     1393                if ( ! isset( $new_array[ $key ] ) ) 
    13951394                    $new_array[ $key ] = $row; 
    13961395            } 
     
    14261425        if ( $this->col_info ) { 
    14271426            if ( $col_offset == -1 ) { 
    1428                 $i         = 0; 
     1427                $i = 0; 
    14291428                $new_array = array(); 
    14301429                foreach( (array) $this->col_info as $col ) { 
     
    15721571} 
    15731572 
    1574 if ( ! isset($wpdb) ) { 
     1573if ( ! isset( $wpdb ) ) { 
    15751574    /** 
    15761575     * WordPress Database Object, if it isn't set already in wp-content/db.php 
     
    15781577     * @since 0.71 
    15791578     */ 
    1580     $wpdb = new wpdb(DB_USER, DB_PASSWORD, DB_NAME, DB_HOST); 
     1579    $wpdb = new wpdb( DB_USER, DB_PASSWORD, DB_NAME, DB_HOST ); 
    15811580} 
    15821581?> 
Note: See TracChangeset for help on using the changeset viewer.