doesn't seem to work with db table prefix
| Project: | #translatable |
| Version: | 5.x-1.2 |
| Component: | Code |
| Category: | bug report |
| Priority: | normal |
| Assigned: | sun |
| Status: | closed |
Hi, I just tried to translate a menu in a database called 'choir' that is also using table prefixes. I get the following error messages:
* user warning: Table 'choir.translatable_object' doesn't exist query: INSERT INTO translatable_object (tid,object_name,object_key,object_field,translation,locale) VALUES (3,'menu','133','title','Der Chor','de') in D:\wamp\drupal5\includes\database.mysql.inc on line 172.
* user warning: Table 'choir.translatable_object' doesn't exist query: INSERT INTO translatable_object (tid,object_name,object_key,object_field,translation,locale) VALUES (4,'menu','133','description','Über den Chor','de') in D:\wamp\drupal5\includes\database.mysql.inc on line 172.
It seems that the table prefix is not applied.

#1
Ok, to fix this one has to change line 179 in translatable.database.inc into:
<?phpdb_query("INSERT INTO {{$table}} (". implode(',', $fields['columns']) .") VALUES (". implode(',', $fields['types']) .")", $fields['values']);
?>
Patch is attached.
I presume that line 210 in this file is also not working with prefixes:
<?phpreturn db_query("UPDATE {$table} SET "...
?>
The curly braces will be parsed by php as delimiters of the variable name to be replaced. So one can either use two curly braces:
<?phpreturn db_query("UPDATE {{$table}} SET "...
?>
or pass the table name as a parameter to the db_query function:
<?phpreturn db_query("UPDATE {%s} SET ...", $table
?>
#2
Thanks for this bug report. Please test attached patch.
#3
Seems to work fine on a system with table prefixes. I made sure both the insert and the update case were executed.
#4
Thanks, committed.
#5
Automatically closed -- issue fixed for two weeks with no activity.