WordPress.org

Make WordPress Core


Ignore:
Timestamp:
05/06/2015 09:03:13 PM (6 years ago)
Author:
johnbillion
Message:

WPDB: Allow queries to reference tables in the dbname.tablename format, and allow table names to contain any valid character, rather than just ASCII.

Merge of [32368] to the 4.0 branch.

Props pento, willstedt for the initial patch.

See #32090.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/4.0/tests/phpunit/tests/db.php

    r32388 r32413  
    492492    function data_get_table_from_query() {
    493493        $table = 'a_test_table_name';
     494        $db_table = '`a_test_db`.`another_test_table`';
    494495
    495496        $queries = array(
     
    594595        );
    595596
    596         foreach ( $queries as &$query ) {
    597             $query = array( $query, $table );
     597        $querycount = count( $queries );
     598        for ( $ii = 0; $ii < $querycount; $ii++ ) {
     599            $db_query = str_replace( $table, $db_table, $queries[ $ii ] );
     600            $expected_db_table = str_replace( '`', '', $db_table );
     601
     602            $queries[ $ii ] = array( $queries[ $ii ], $table );
     603            $queries[] = array( $db_query, $expected_db_table );
    598604        }
    599605        return $queries;
Note: See TracChangeset for help on using the changeset viewer.