I'm trying to use the database functions to connect to an external database called wikibox_db using the following
$dbr =& wfGetDB( DB_SLAVE ); $dbr->debug(true); $dbr->selectDB('wikibox_db'); $output .= "\n\nQuery:".$dbr->lastQuery()."<br>\n\n"; $res = $dbr->select( 'wikibox_db.box', '*' );
This gives the following error on the special page I'm working on:
A database query syntax error has occurred. This may indicate a bug in the software. The last attempted database query was: (SQL query hidden) from within function "Database::select". MySQL returned error "1103: Incorrect table name 'wikibox_db.box' (jim-hus-computer.local)".
Not surprisingly, it works if I query a table in the mediawiki schema. Two questions: 1) Anyone know how to do this? 2) How do I set the wiki to not hide the sql query from me?
Thanks!
Jim ===================================== Jim Hu Associate Professor Dept. of Biochemistry and Biophysics 2128 TAMU Texas A&M Univ. College Station, TX 77843-2128 979-862-4054
On 27/02/07, Jim Hu jimhu@tamu.edu wrote:
from within function "Database::select". MySQL returned error "1103: Incorrect table name 'wikibox_db.box' (jim-hus-computer.local)".
You're using one of the query builder functions, which will automatically add the database name and table prefix to the table name passed to them. This is noted in the documentation, albeit the wrong documentation - it's in the comment for Database::tableName().
To work around this, either:
1. Use Database::query() directly 2. Wrap the table name in `backquotes` and the database functions won't mess with it
- How do I set the wiki to not hide the sql query from me?
$wgShowSQLErrors = true;
Rob Church
Thanks, Rob!
Here's what I am doing now. In my class constructor, I'm doing
$this->dbr =& wfGetDB( DB_SLAVE );
Then I use $this->dbr->query($sql) a lot in the methods. I'm not reseting the db at all, since it seems to work if I just give the dbname.tablename in the query. Seems to work so far...fingers crossed on getting the rest of it to work.
Best, Jim ===================================== Jim Hu Associate Professor Dept. of Biochemistry and Biophysics 2128 TAMU Texas A&M Univ. College Station, TX 77843-2128 979-862-4054
On Feb 27, 2007, at 12:33 PM, Rob Church wrote:
On 27/02/07, Jim Hu jimhu@tamu.edu wrote:
from within function "Database::select". MySQL returned error "1103: Incorrect table name 'wikibox_db.box' (jim-hus-computer.local)".
You're using one of the query builder functions, which will automatically add the database name and table prefix to the table name passed to them. This is noted in the documentation, albeit the wrong documentation - it's in the comment for Database::tableName().
To work around this, either:
- Use Database::query() directly
- Wrap the table name in `backquotes` and the database functions
won't mess with it
- How do I set the wiki to not hide the sql query from me?
$wgShowSQLErrors = true;
Rob Church
Wikitech-l mailing list Wikitech-l@lists.wikimedia.org http://lists.wikimedia.org/mailman/listinfo/wikitech-l
wikitech-l@lists.wikimedia.org