Skip to content

Commit b57d8d1

Browse files
committed
Some wpdb cleanups.
git-svn-id: https://develop.svn.wordpress.org/trunk@14058 602fd350-edb4-49c9-b593-d223f7449a82
1 parent 8823027 commit b57d8d1

1 file changed

Lines changed: 15 additions & 16 deletions

File tree

wp-includes/wp-db.php

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -22,17 +22,17 @@
2222
/**
2323
* @since 2.5.0
2424
*/
25-
define( 'OBJECT_K', 'OBJECT_K', false );
25+
define( 'OBJECT_K', 'OBJECT_K' );
2626

2727
/**
2828
* @since 0.71
2929
*/
30-
define( 'ARRAY_A', 'ARRAY_A', false );
30+
define( 'ARRAY_A', 'ARRAY_A' );
3131

3232
/**
3333
* @since 0.71
3434
*/
35-
define( 'ARRAY_N', 'ARRAY_N', false );
35+
define( 'ARRAY_N', 'ARRAY_N' );
3636

3737
/**
3838
* WordPress Database Access Abstraction Object
@@ -578,7 +578,7 @@ function set_prefix( $prefix, $set_table_names = true ) {
578578
if ( defined( 'VHOST' ) && empty( $this->blogid ) )
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 )
584584
$this->$table = $prefixed_table;
@@ -605,7 +605,7 @@ function set_blog_id( $blog_id, $site_id = 0 ) {
605605
$old_blog_id = $this->blogid;
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 )
611611
$this->$table = $prefixed_table;
@@ -624,9 +624,9 @@ function set_blog_id( $blog_id, $site_id = 0 ) {
624624
* @param int $blog_id Optional.
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 ) )
632632
return $this->base_prefix;
@@ -837,16 +837,15 @@ function escape_by_ref( &$string ) {
837837
}
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:
843843
* %d (decimal number)
844844
* %s (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).
852851
* Does not support sign, padding, alignment, width or precision specifiers.
@@ -1355,7 +1354,7 @@ function get_col( $query = null , $x = 0 ) {
13551354

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
}
13611360
return $new_array;
@@ -1391,7 +1390,7 @@ function get_results( $query = null, $output = OBJECT ) {
13911390
// (Duplicates are discarded)
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
}
13971396
return $new_array;
@@ -1425,7 +1424,7 @@ function get_results( $query = null, $output = OBJECT ) {
14251424
function get_col_info( $info_type = 'name', $col_offset = -1 ) {
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 ) {
14311430
$new_array[$i] = $col->{$info_type};
@@ -1571,12 +1570,12 @@ function db_version() {
15711570
}
15721571
}
15731572

1574-
if ( ! isset($wpdb) ) {
1573+
if ( ! isset( $wpdb ) ) {
15751574
/**
15761575
* WordPress Database Object, if it isn't set already in wp-content/db.php
15771576
* @global object $wpdb Creates a new wpdb object based on wp-config.php Constants for the database
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
?>

0 commit comments

Comments
 (0)