﻿id	summary	reporter	owner	description	type	status	priority	milestone	component	version	severity	resolution	keywords	cc
13323	CUSTOM_USER_TABLE disables $wpdb->insert.	hanifb	ryan	"If you have a custom_user_table on a different database than your wordpress install, the $wpdb->insert stops functioning.


== Example: ==


Wordpress is installed on database_1 and the custom user table is on database_2.

{{{
define('CUSTOM_USER_TABLE', 'database_2.prefix_users');
}}}
 

The insert code is in wp-includes/wp-db.php
{{{
$sql= ""{$type} INTO `$table` (`"" . implode( '`,`', $fields ) . ""`) VALUES ('"" . implode( ""','"", $formatted_fields ) . ""')"";
}}}
As you clearly can see, the result will be 
{{{
`database_2.prefix_users`
}}}

That of course breaks the sql query, Because you may have a 
{{{
database_2.`prefix_users`
}}}

or 

{{{
database_2.prefix_users
}}}

but you may not have the database name wrapped in single quotes.


== Solution: ==

In both the $wpdb->_insert_replace_helper and $wpdb->update, insert this before the query.
{{{
if(strpos($table,'.') === false) {
	$table = ""`$table`"";
	} else {
	$table = ""$table"";
	}
$sql= ""{$type} INTO $table (`"" . implode( '`,`', $fields ) . ""`) VALUES ('"" . implode( ""','"", $formatted_fields ) . ""')"";
}}}

Any comments?"	feature request	closed	normal		Database	3.0	normal	wontfix	close	
