Hey guys,
It's been a while since I've done anything with MediaWiki,and I've been looking on mediawiki.org and didn't find the answer to this question so far.
I've got a 3rd party package written in PHP that uses MySQL as a database back-end, and while I like what the package does, it is poorly written from a programming standpoint (lots of security vulnerabilities). It also does not have the capabilities of community editing, which is going to be an important feature for a website I'm architecting.
I'd like to incorporate this package via a large MediaWiki extension into MediaWiki, using the basic table layouts from the existing package. The main issue I see so far is table name conflicts, which are easily solvable with different table prefixes.
However, I'm looking for a way to use the MediaWiki abstraction layer to access the tables from this third party package, and I need to be able to interact with the tables, including all CRUD functions.
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.
Or, if you have pointers on how best to make this happen without resorting to native mysql query or using the PHP PDO, I'm open to suggestions here. I'd really like to use the MediaWiki db abstraction layer if possible.
Thanks!
Lisa Ridley
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
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.
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.
mediawiki-l@lists.wikimedia.org