wp_set_wpdb_vars

The timeline below displays how wordpress function wp_set_wpdb_vars has changed across different WordPress versions. If a version is not listed, refer to the next available version below.

WordPress Version: 6.3

/**
 * Sets the database table prefix and the format specifiers for database
 * table columns.
 *
 * Columns not listed here default to `%s`.
 *
 * @since 3.0.0
 * @access private
 *
 * @global wpdb   $wpdb         WordPress database abstraction object.
 * @global string $table_prefix The database table prefix.
 */
function wp_set_wpdb_vars()
{
    global $wpdb, $table_prefix;
    if (!empty($wpdb->error)) {
        dead_db();
    }
    $wpdb->field_types = array(
        'post_author' => '%d',
        'post_parent' => '%d',
        'menu_order' => '%d',
        'term_id' => '%d',
        'term_group' => '%d',
        'term_taxonomy_id' => '%d',
        'parent' => '%d',
        'count' => '%d',
        'object_id' => '%d',
        'term_order' => '%d',
        'ID' => '%d',
        'comment_ID' => '%d',
        'comment_post_ID' => '%d',
        'comment_parent' => '%d',
        'user_id' => '%d',
        'link_id' => '%d',
        'link_owner' => '%d',
        'link_rating' => '%d',
        'option_id' => '%d',
        'blog_id' => '%d',
        'meta_id' => '%d',
        'post_id' => '%d',
        'user_status' => '%d',
        'umeta_id' => '%d',
        'comment_karma' => '%d',
        'comment_count' => '%d',
        // Multisite:
        'active' => '%d',
        'cat_id' => '%d',
        'deleted' => '%d',
        'lang_id' => '%d',
        'mature' => '%d',
        'public' => '%d',
        'site_id' => '%d',
        'spam' => '%d',
    );
    $prefix = $wpdb->set_prefix($table_prefix);
    if (is_wp_error($prefix)) {
        wp_load_translations_early();
        wp_die(sprintf(
            /* translators: 1: $table_prefix, 2: wp-config.php */
            __('<strong>Error:</strong> %1$s in %2$s can only contain numbers, letters, and underscores.'),
            '<code>$table_prefix</code>',
            '<code>wp-config.php</code>'
        ));
    }
}

WordPress Version: 6.1

/**
 * Set the database table prefix and the format specifiers for database
 * table columns.
 *
 * Columns not listed here default to `%s`.
 *
 * @since 3.0.0
 * @access private
 *
 * @global wpdb   $wpdb         WordPress database abstraction object.
 * @global string $table_prefix The database table prefix.
 */
function wp_set_wpdb_vars()
{
    global $wpdb, $table_prefix;
    if (!empty($wpdb->error)) {
        dead_db();
    }
    $wpdb->field_types = array(
        'post_author' => '%d',
        'post_parent' => '%d',
        'menu_order' => '%d',
        'term_id' => '%d',
        'term_group' => '%d',
        'term_taxonomy_id' => '%d',
        'parent' => '%d',
        'count' => '%d',
        'object_id' => '%d',
        'term_order' => '%d',
        'ID' => '%d',
        'comment_ID' => '%d',
        'comment_post_ID' => '%d',
        'comment_parent' => '%d',
        'user_id' => '%d',
        'link_id' => '%d',
        'link_owner' => '%d',
        'link_rating' => '%d',
        'option_id' => '%d',
        'blog_id' => '%d',
        'meta_id' => '%d',
        'post_id' => '%d',
        'user_status' => '%d',
        'umeta_id' => '%d',
        'comment_karma' => '%d',
        'comment_count' => '%d',
        // Multisite:
        'active' => '%d',
        'cat_id' => '%d',
        'deleted' => '%d',
        'lang_id' => '%d',
        'mature' => '%d',
        'public' => '%d',
        'site_id' => '%d',
        'spam' => '%d',
    );
    $prefix = $wpdb->set_prefix($table_prefix);
    if (is_wp_error($prefix)) {
        wp_load_translations_early();
        wp_die(sprintf(
            /* translators: 1: $table_prefix, 2: wp-config.php */
            __('<strong>Error:</strong> %1$s in %2$s can only contain numbers, letters, and underscores.'),
            '<code>$table_prefix</code>',
            '<code>wp-config.php</code>'
        ));
    }
}

WordPress Version: 5.4

/**
 * Set the database table prefix and the format specifiers for database
 * table columns.
 *
 * Columns not listed here default to `%s`.
 *
 * @since 3.0.0
 * @access private
 *
 * @global wpdb   $wpdb         WordPress database abstraction object.
 * @global string $table_prefix The database table prefix.
 */
function wp_set_wpdb_vars()
{
    global $wpdb, $table_prefix;
    if (!empty($wpdb->error)) {
        dead_db();
    }
    $wpdb->field_types = array(
        'post_author' => '%d',
        'post_parent' => '%d',
        'menu_order' => '%d',
        'term_id' => '%d',
        'term_group' => '%d',
        'term_taxonomy_id' => '%d',
        'parent' => '%d',
        'count' => '%d',
        'object_id' => '%d',
        'term_order' => '%d',
        'ID' => '%d',
        'comment_ID' => '%d',
        'comment_post_ID' => '%d',
        'comment_parent' => '%d',
        'user_id' => '%d',
        'link_id' => '%d',
        'link_owner' => '%d',
        'link_rating' => '%d',
        'option_id' => '%d',
        'blog_id' => '%d',
        'meta_id' => '%d',
        'post_id' => '%d',
        'user_status' => '%d',
        'umeta_id' => '%d',
        'comment_karma' => '%d',
        'comment_count' => '%d',
        // Multisite:
        'active' => '%d',
        'cat_id' => '%d',
        'deleted' => '%d',
        'lang_id' => '%d',
        'mature' => '%d',
        'public' => '%d',
        'site_id' => '%d',
        'spam' => '%d',
    );
    $prefix = $wpdb->set_prefix($table_prefix);
    if (is_wp_error($prefix)) {
        wp_load_translations_early();
        wp_die(sprintf(
            /* translators: 1: $table_prefix, 2: wp-config.php */
            __('<strong>Error</strong>: %1$s in %2$s can only contain numbers, letters, and underscores.'),
            '<code>$table_prefix</code>',
            '<code>wp-config.php</code>'
        ));
    }
}

WordPress Version: 5.3

/**
 * Set the database table prefix and the format specifiers for database
 * table columns.
 *
 * Columns not listed here default to `%s`.
 *
 * @since 3.0.0
 * @access private
 *
 * @global wpdb   $wpdb         WordPress database abstraction object.
 * @global string $table_prefix The database table prefix.
 */
function wp_set_wpdb_vars()
{
    global $wpdb, $table_prefix;
    if (!empty($wpdb->error)) {
        dead_db();
    }
    $wpdb->field_types = array(
        'post_author' => '%d',
        'post_parent' => '%d',
        'menu_order' => '%d',
        'term_id' => '%d',
        'term_group' => '%d',
        'term_taxonomy_id' => '%d',
        'parent' => '%d',
        'count' => '%d',
        'object_id' => '%d',
        'term_order' => '%d',
        'ID' => '%d',
        'comment_ID' => '%d',
        'comment_post_ID' => '%d',
        'comment_parent' => '%d',
        'user_id' => '%d',
        'link_id' => '%d',
        'link_owner' => '%d',
        'link_rating' => '%d',
        'option_id' => '%d',
        'blog_id' => '%d',
        'meta_id' => '%d',
        'post_id' => '%d',
        'user_status' => '%d',
        'umeta_id' => '%d',
        'comment_karma' => '%d',
        'comment_count' => '%d',
        // multisite:
        'active' => '%d',
        'cat_id' => '%d',
        'deleted' => '%d',
        'lang_id' => '%d',
        'mature' => '%d',
        'public' => '%d',
        'site_id' => '%d',
        'spam' => '%d',
    );
    $prefix = $wpdb->set_prefix($table_prefix);
    if (is_wp_error($prefix)) {
        wp_load_translations_early();
        wp_die(sprintf(
            /* translators: 1: $table_prefix, 2: wp-config.php */
            __('<strong>ERROR</strong>: %1$s in %2$s can only contain numbers, letters, and underscores.'),
            '<code>$table_prefix</code>',
            '<code>wp-config.php</code>'
        ));
    }
}

WordPress Version: 5.1

/**
 * Set the database table prefix and the format specifiers for database
 * table columns.
 *
 * Columns not listed here default to `%s`.
 *
 * @since 3.0.0
 * @access private
 *
 * @global wpdb   $wpdb         The WordPress database class.
 * @global string $table_prefix The database table prefix.
 */
function wp_set_wpdb_vars()
{
    global $wpdb, $table_prefix;
    if (!empty($wpdb->error)) {
        dead_db();
    }
    $wpdb->field_types = array(
        'post_author' => '%d',
        'post_parent' => '%d',
        'menu_order' => '%d',
        'term_id' => '%d',
        'term_group' => '%d',
        'term_taxonomy_id' => '%d',
        'parent' => '%d',
        'count' => '%d',
        'object_id' => '%d',
        'term_order' => '%d',
        'ID' => '%d',
        'comment_ID' => '%d',
        'comment_post_ID' => '%d',
        'comment_parent' => '%d',
        'user_id' => '%d',
        'link_id' => '%d',
        'link_owner' => '%d',
        'link_rating' => '%d',
        'option_id' => '%d',
        'blog_id' => '%d',
        'meta_id' => '%d',
        'post_id' => '%d',
        'user_status' => '%d',
        'umeta_id' => '%d',
        'comment_karma' => '%d',
        'comment_count' => '%d',
        // multisite:
        'active' => '%d',
        'cat_id' => '%d',
        'deleted' => '%d',
        'lang_id' => '%d',
        'mature' => '%d',
        'public' => '%d',
        'site_id' => '%d',
        'spam' => '%d',
    );
    $prefix = $wpdb->set_prefix($table_prefix);
    if (is_wp_error($prefix)) {
        wp_load_translations_early();
        wp_die(
            /* translators: 1: $table_prefix, 2: wp-config.php */
            sprintf(__('<strong>ERROR</strong>: %1$s in %2$s can only contain numbers, letters, and underscores.'), '<code>$table_prefix</code>', '<code>wp-config.php</code>')
        );
    }
}

WordPress Version: 4.4

/**
 * Set the database table prefix and the format specifiers for database
 * table columns.
 *
 * Columns not listed here default to `%s`.
 *
 * @since 3.0.0
 * @access private
 *
 * @global wpdb   $wpdb         The WordPress database class.
 * @global string $table_prefix The database table prefix.
 */
function wp_set_wpdb_vars()
{
    global $wpdb, $table_prefix;
    if (!empty($wpdb->error)) {
        dead_db();
    }
    $wpdb->field_types = array(
        'post_author' => '%d',
        'post_parent' => '%d',
        'menu_order' => '%d',
        'term_id' => '%d',
        'term_group' => '%d',
        'term_taxonomy_id' => '%d',
        'parent' => '%d',
        'count' => '%d',
        'object_id' => '%d',
        'term_order' => '%d',
        'ID' => '%d',
        'comment_ID' => '%d',
        'comment_post_ID' => '%d',
        'comment_parent' => '%d',
        'user_id' => '%d',
        'link_id' => '%d',
        'link_owner' => '%d',
        'link_rating' => '%d',
        'option_id' => '%d',
        'blog_id' => '%d',
        'meta_id' => '%d',
        'post_id' => '%d',
        'user_status' => '%d',
        'umeta_id' => '%d',
        'comment_karma' => '%d',
        'comment_count' => '%d',
        // multisite:
        'active' => '%d',
        'cat_id' => '%d',
        'deleted' => '%d',
        'lang_id' => '%d',
        'mature' => '%d',
        'public' => '%d',
        'site_id' => '%d',
        'spam' => '%d',
    );
    $prefix = $wpdb->set_prefix($table_prefix);
    if (is_wp_error($prefix)) {
        wp_load_translations_early();
        wp_die(
            /* translators: 1: $table_prefix 2: wp-config.php */
            sprintf(__('<strong>ERROR</strong>: %1$s in %2$s can only contain numbers, letters, and underscores.'), '<code>$table_prefix</code>', '<code>wp-config.php</code>')
        );
    }
}

WordPress Version: 4.0

/**
 * Set the database table prefix and the format specifiers for database
 * table columns.
 *
 * Columns not listed here default to `%s`.
 *
 * @since 3.0.0
 * @access private
 *
 * @global wpdb   $wpdb         The WordPress database class.
 * @global string $table_prefix The database table prefix.
 */
function wp_set_wpdb_vars()
{
    global $wpdb, $table_prefix;
    if (!empty($wpdb->error)) {
        dead_db();
    }
    $wpdb->field_types = array(
        'post_author' => '%d',
        'post_parent' => '%d',
        'menu_order' => '%d',
        'term_id' => '%d',
        'term_group' => '%d',
        'term_taxonomy_id' => '%d',
        'parent' => '%d',
        'count' => '%d',
        'object_id' => '%d',
        'term_order' => '%d',
        'ID' => '%d',
        'comment_ID' => '%d',
        'comment_post_ID' => '%d',
        'comment_parent' => '%d',
        'user_id' => '%d',
        'link_id' => '%d',
        'link_owner' => '%d',
        'link_rating' => '%d',
        'option_id' => '%d',
        'blog_id' => '%d',
        'meta_id' => '%d',
        'post_id' => '%d',
        'user_status' => '%d',
        'umeta_id' => '%d',
        'comment_karma' => '%d',
        'comment_count' => '%d',
        // multisite:
        'active' => '%d',
        'cat_id' => '%d',
        'deleted' => '%d',
        'lang_id' => '%d',
        'mature' => '%d',
        'public' => '%d',
        'site_id' => '%d',
        'spam' => '%d',
    );
    $prefix = $wpdb->set_prefix($table_prefix);
    if (is_wp_error($prefix)) {
        wp_load_translations_early();
        wp_die(__('<strong>ERROR</strong>: <code>$table_prefix</code> in <code>wp-config.php</code> can only contain numbers, letters, and underscores.'));
    }
}

WordPress Version: 3.7

/**
 * Sets the database table prefix and the format specifiers for database table columns.
 *
 * Columns not listed here default to %s.
 *
 * @see wpdb::$field_types Since 2.8.0
 * @see wpdb::prepare()
 * @see wpdb::insert()
 * @see wpdb::update()
 * @see wpdb::set_prefix()
 *
 * @access private
 * @since 3.0.0
 */
function wp_set_wpdb_vars()
{
    global $wpdb, $table_prefix;
    if (!empty($wpdb->error)) {
        dead_db();
    }
    $wpdb->field_types = array(
        'post_author' => '%d',
        'post_parent' => '%d',
        'menu_order' => '%d',
        'term_id' => '%d',
        'term_group' => '%d',
        'term_taxonomy_id' => '%d',
        'parent' => '%d',
        'count' => '%d',
        'object_id' => '%d',
        'term_order' => '%d',
        'ID' => '%d',
        'comment_ID' => '%d',
        'comment_post_ID' => '%d',
        'comment_parent' => '%d',
        'user_id' => '%d',
        'link_id' => '%d',
        'link_owner' => '%d',
        'link_rating' => '%d',
        'option_id' => '%d',
        'blog_id' => '%d',
        'meta_id' => '%d',
        'post_id' => '%d',
        'user_status' => '%d',
        'umeta_id' => '%d',
        'comment_karma' => '%d',
        'comment_count' => '%d',
        // multisite:
        'active' => '%d',
        'cat_id' => '%d',
        'deleted' => '%d',
        'lang_id' => '%d',
        'mature' => '%d',
        'public' => '%d',
        'site_id' => '%d',
        'spam' => '%d',
    );
    $prefix = $wpdb->set_prefix($table_prefix);
    if (is_wp_error($prefix)) {
        wp_load_translations_early();
        wp_die(__('<strong>ERROR</strong>: <code>$table_prefix</code> in <code>wp-config.php</code> can only contain numbers, letters, and underscores.'));
    }
}