I know that it has been discussed before and I retrieved the scripts from Lars Gregori (but they have not been updated since 2001).

So, is there an interest from the rest of the community in implementing a prefix on the database tables?

Let the discussion begin !

Comments

Dries’s picture

Gary has been working on database prefix code recently. Check his sandbox in the contributions repository. Feel free to help.

mlawren’s picture

Hello all,

I hope that this is read by someone, and not dropped because it is on an old thread...

There is a serious problem with the db_prefix_tables implementation. What this function appears to do is remove all occurances of "{" and "}" in an SQL query. It does this based on the convention of specifying prefixable database names like "{user}".

Unfortunately this breaks queries which have serialized data such as arrays. Serialized arrays have the form:

a:1:{s:9:"ldap_pass";s:8:"get$real";}

I have just spent several hours trying to track down why the ldap_authentication module wouldn't work right, and it was due to this :)

My fix would be to turn this:

return strtr($sql, array("{" => $db_prefix, "}" => ""));

into this:

return strtr($sql, array(" {" => " ".$db_prefix, "} " => " "));

This should work for most cases because serialized data in an sql query is usually surrounded by single quotes, and not a trailing space. Thoughts?

Regards, Mark.

mlawren’s picture

Just discovered we should also check for the "}." case as well. Ie queries which go "SELECT {users}.[fields]..."

moshe weitzman’s picture

Are you using latest CVS? Dries committed a patch to database API by Gerhard a few days ago which should have fixed this.