WordPress.org

Make WordPress Core

Changeset 13376


Ignore:
Timestamp:
02/24/2010 06:58:52 PM (8 years ago)
Author:
nacin
Message:

More wpdb cleanups, see #12362

File:
1 edited

Legend:

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

    r13357 r13376  
    569569        $this->prefix = $this->get_blog_prefix( $this->blogid );
    570570
    571         foreach ( (array) $this->tables( 'blog' ) as $table => $prefixed_table )
     571        foreach ( $this->tables( 'blog' ) as $table => $prefixed_table )
    572572            $this->$table = $prefixed_table;
    573573
    574         foreach ( (array) $this->tables( 'old' ) as $table => $prefixed_table )
     574        foreach ( $this->tables( 'old' ) as $table => $prefixed_table )
    575575            $this->$table = $prefixed_table;
    576576
     
    631631     * be determined by the prefix.
    632632     *
     633     * The scope argument can take one of the following:
     634     *
     635     * 'all' - returns 'all' and 'global' tables. No old tables are returned.
     636     * 'global' - returns the global tables for the installation, returning multisite tables only if running multisite.
     637     * 'ms_global' - returns the multisite global tables, regardless if current installation is multisite.
     638     * 'blog' - returns the blog-level tables for the queried blog.
     639     * 'old' - returns tables which are deprecated.
     640     *
    633641     * @since 3.0.0
    634642     * @uses wpdb::$tables
     
    638646     * @uses is_multisite()
    639647     *
    640      * @param string $scope Can be all, global, ms_global, blog, or old tables. Defaults to all.
    641      *  'all' returns 'all' and 'global' tables. No old tables are returned.
    642      *  'global' returns the global tables for the installation, returning multisite tables only if running multisite.
    643      *  'ms_global' returns the multisite global tables, regardless if current installation is multisite.
    644      *  'blog' returns the blog-level tables for the queried blog.
    645      *  'old' returns tables which are deprecated.
    646      * @param bool $prefix Whether to include table prefixes. Default true. If blog
     648     * @param string $scope Optional. Can be all, global, ms_global, blog, or old tables. Defaults to all.
     649     * @param bool $prefix Optional. Whether to include table prefixes. Default true. If blog
    647650     *  prefix is requested, then the custom users and usermeta tables will be mapped.
    648      * @param int $blog_id The blog_id to prefix. Defaults to wpdb::blogid. Used only when prefix is requested.
     651     * @param int $blog_id Optional. The blog_id to prefix. Defaults to wpdb::blogid. Used only when prefix is requested.
    649652     * @return array Table names. When a prefix is requested, the key is the unprefixed table name.
    650653     */
    651654    function tables( $scope = 'all', $prefix = true, $blog_id = 0 ) {
    652655        switch ( $scope ) {
    653             case 'old' :
    654                 $tables = $this->old_tables;
    655                 break;
    656             case 'blog' :
    657                 $tables = $this->tables;
    658                 break;
    659             case 'ms_global' :
    660                 $tables = $this->ms_global_tables;
     656            case 'all' :
     657                $tables = array_merge( $this->global_tables, $this->tables );
     658                if ( is_multisite() )
     659                    $tables = array_merge( $tables, $this->ms_global_tables );
    661660                break;
    662661            case 'global' :
     
    665664                    $tables = array_merge( $tables, $this->ms_global_tables );
    666665                break;
    667             case 'all' :
    668                 $tables = array_merge( $this->global_tables, $this->tables );
    669                 if ( is_multisite() )
    670                     $tables = array_merge( $tables, $this->ms_global_tables );
     666            case 'ms_global' :
     667                $tables = $this->ms_global_tables;
     668                break;
     669            case 'blog' :
     670                $tables = $this->tables;
     671                break;
     672            case 'old' :
     673                $tables = $this->old_tables;
     674                break;
     675            default :
     676                return array();
    671677                break;
    672678        }
     
    724730
    725731    /**
    726      * Weak escape
    727      *
    728      * @uses addslashes()
     732     * Weak escape, using addslashes()
     733     *
     734     * @see addslashes()
    729735     * @since {@internal Version Unknown}}
    730736     * @access private
     
    738744
    739745    /**
    740      * Real escape
    741      *
    742      * @uses mysql_real_escape_string()
    743      * @uses addslashes()
     746     * Real escape, using mysql_real_escape_string() or addslashes()
     747     *
     748     * @see mysql_real_escape_string()
     749     * @see addslashes()
    744750     * @since 2.8
    745751     * @access private
     
    787793     *
    788794     * @since 0.71
    789      * @param  string|array $data to escape
     795     * @param string|array $data to escape
    790796     * @return string|array escaped as query safe string
    791797     */
     
    810816     * @uses wpdb::_real_escape()
    811817     * @since 2.3.0
    812      * @param  string $string to escape
     818     * @param string $string to escape
    813819     * @return void
    814820     */
     
    14571463     *
    14581464     * @param string $db_cap the feature
    1459      * @param false|string|resource $dbh_or_table. Not implemented.
    14601465     * @return bool
    14611466     */
     
    14901495            if ( isset( $call['class'] ) && __CLASS__ == $call['class'] )
    14911496                continue; // Filter out wpdb calls.
    1492         }
    1493         $caller = join( ', ', $caller );
    1494 
    1495         return $caller;
     1497            $caller[] = isset( $call['class'] ) ? "{$call['class']}->{$call['function']}" : $call['function'];
     1498        }
     1499
     1500        return join( ', ', $caller );
    14961501    }
    14971502
     
    14991504     * The database version number.
    15001505     *
    1501      * @param false|string|resource $dbh_or_table. Not implemented.
    15021506     * @return false|string false on failure, version number on success
    15031507     */
Note: See TracChangeset for help on using the changeset viewer.