Support » Alpha/Beta/RC » where are the “// Table names-prefix” in 2.5?

  • Resolved beku76

    (@beku76)


    hi,
    before the // Table prefixes were editable in wp-settings.php,
    now I installed 2.5 and I can’t find them anymore 🙁

    where are they?
    I need to edit because I run 3 wordpress with shared posts in 1 database.

    thanks so much

Viewing 6 replies - 1 through 6 (of 6 total)
  • The table prefix setting was in wp-config.php before, and it is still there now.

    If you mean where are the table names defined, there’s a function called “set_prefix” in wp-db.php that adds the prefix onto the table names.

    yes,
    thanks for clarifying it Otto,
    I found the “set_prefix” in wp-db.php
    but I’m afraid this is not what I was looking for…
    or at least I don’t know how to use it…
    sorry,

    in 2.3, the wp-settings.php had this inside:

    // Table names
    $wpdb->posts = $wpdb->prefix . ‘posts’;
    $wpdb->users = $wpdb->prefix . ‘users’;
    $wpdb->categories = $wpdb->prefix . ‘categories’;
    $wpdb->post2cat = $wpdb->prefix . ‘post2cat’;
    $wpdb->comments = $wpdb->prefix . ‘comments’;
    $wpdb->link2cat = $wpdb->prefix . ‘link2cat’;
    $wpdb->links = $wpdb->prefix . ‘links’;
    $wpdb->options = ‘blog_A_options’;
    $wpdb->postmeta = $wpdb->prefix . ‘postmeta’;
    $wpdb->usermeta = $wpdb->prefix . ‘usermeta’;
    $wpdb->terms = $wpdb->prefix . ‘terms’;
    $wpdb->term_taxonomy = $wpdb->prefix . ‘term_taxonomy’;
    $wpdb->term_relationships = $wpdb->prefix . ‘term_relationships’;

    *I need to have a custom name for $wpdb->options
    where to change this?

    thanks!

    Actually, yes, the set_prefix function is exactly what you’re looking for. WordPress does not do it that same way anymore. That loop in set_prefix is setting those values.

    You can add the
    $this->options = 'blog_A_options'; line there in the set_prefix function, after the foreach loop.

    thanks for the prompt reply,
    I copied the line you wrote at the end of the set_prefix function…
    but I think I did it wrong, because it didn’t worked 🙁

    here is how it looks:

    function set_prefix($prefix) {
    
    		if ( preg_match('|[^a-z0-9_]|i', $prefix) )
    			return new WP_Error('invalid_db_prefix', 'Invalid database prefix'); // No gettext here
    
    		$old_prefix = $this->prefix;
    		$this->prefix = $prefix;
    
    		foreach ( $this->tables as $table )
    			$this->$table = $this->prefix . $table;
    
    		if ( defined('CUSTOM_USER_TABLE') )
    			$this->users = CUSTOM_USER_TABLE;
    
    		if ( defined('CUSTOM_USER_META_TABLE') )
    			$this->usermeta = CUSTOM_USER_META_TABLE;
    
    		return $old_prefix;
    
    	$this->options = 'blog_A_options';
    	}

    I hope you are still nearby and can help me to solve this issue
    thanks!

    That’s because you put it in the wrong place, after the return line. I told you to put it after the foreach loop. You can’t just put code anywhere you like, it runs in order, you know.

    ...
    foreach ( $this->tables as $table )
    	$this->$table = $this->prefix . $table;
    
    $this->options = 'blog_A_options';
    ...

    Thanks Otto
    it worked perfectly.

    I’m sorry for the misunderstanding…
    I though that the foreach loop lasted until the end…

    I’m glad I learned something new today,
    thanks

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘where are the “// Table names-prefix” in 2.5?’ is closed to new replies.