wp_set_wpdb_vars

Set the database table prefix and the format specifiers for database table columns.

Description

wp_set_wpdb_vars(); 

Columns not listed here default to %s..


Usage

  1. if ( !function_exists( 'wp_set_wpdb_vars' ) ) { 
  2. require_once ABSPATH . WPINC . '/load.php'; 
  3.  
  4.  
  5. // NOTICE! Understand what this does before running. 
  6. $result = wp_set_wpdb_vars(); 
  7.  

Defined (1)

The function is defined in the following location(s).

/wp-includes/load.php  
  1. function wp_set_wpdb_vars() { 
  2. global $wpdb, $table_prefix; 
  3. if ( !empty( $wpdb->error ) ) 
  4. dead_db(); 
  5.  
  6. $wpdb->field_types = array( 'post_author' => '%d', 'post_parent' => '%d', 'menu_order' => '%d', 'term_id' => '%d', 'term_group' => '%d', 'term_taxonomy_id' => '%d',  
  7. 'parent' => '%d', 'count' => '%d', 'object_id' => '%d', 'term_order' => '%d', 'ID' => '%d', 'comment_ID' => '%d', 'comment_post_ID' => '%d', 'comment_parent' => '%d',  
  8. 'user_id' => '%d', 'link_id' => '%d', 'link_owner' => '%d', 'link_rating' => '%d', 'option_id' => '%d', 'blog_id' => '%d', 'meta_id' => '%d', 'post_id' => '%d',  
  9. 'user_status' => '%d', 'umeta_id' => '%d', 'comment_karma' => '%d', 'comment_count' => '%d',  
  10. // multisite: 
  11. 'active' => '%d', 'cat_id' => '%d', 'deleted' => '%d', 'lang_id' => '%d', 'mature' => '%d', 'public' => '%d', 'site_id' => '%d', 'spam' => '%d',  
  12. ); 
  13.  
  14. $prefix = $wpdb->set_prefix( $table_prefix ); 
  15.  
  16. if ( is_wp_error( $prefix ) ) { 
  17. wp_die
  18. /** translators: 1: $table_prefix 2: wp-config.php */ 
  19. sprintf( __( '<strong>ERROR</strong>: %1$s in %2$s can only contain numbers, letters, and underscores.' ),  
  20. '<code>$table_prefix</code>',  
  21. '<code>wp-config.php</code>' 
  22. );