On Mon, 19 Dec 2011 14:40:01 -0800, Platonides Platonides@gmail.com wrote:
On 19/12/11 18:20, Brion Vibber wrote:
On Mon, Dec 19, 2011 at 5:36 AM, Lisa Ridley lhridley@gmail.com wrote:
Is there a way to access tables with different prefixes using the MediaWiki db abstraction layer from within the same MediaWiki site? I swear I thought there was, but if it exists I haven't found the documentation on it so far.
I *think* if you quote the names they won't get prefixes applied. But test that, don't take my word for it. :)
-- brion
Yes, that's an option. Another one would be to list them in $wgSharedTables, with an empy . $wgSharedPrefix.
Adding it to shared tables like that sounds a bit too much like a hack.
I wrote some of that tableName code myself, the quoting trick should work fine.
'foo' will be treated as a local table name and have prefixes and shared table stuff applied to it. A quoted name like '`foo`' will be left alone (to do this in a database independent way use $db->addIdentifierQuotes( 'foo' ) and it'll work. Names with a database name applied to them such as 'bar.foo' should end up something like '`bar`.`foo`' with no prefix applied.
Though really, if this is for the local wiki and you're writing an extension to incorporate that into the wiki, and you're already thinking of using prefixes. Then I'd just mandate that table names should be something like {$wgDBprefix}somename_{thetablename} where 'somename' is some short version of the name of the other system you're incorporating the database from. Either that or use a separate database name for the other data.