MySQL username problem - Printable Version +- Community Support for OpenDocMan (Deprecated) (https://forum.opendocman.com) +-- Forum: OpenDocMan Community Discussion (https://forum.opendocman.com/forum-5.html) +--- Forum: OpenDocMan Support - Community Based (https://forum.opendocman.com/forum-6.html) +--- Thread: MySQL username problem (/thread-129.html) |
MySQL username problem - Stephen - 01-13-2010 jltgordon 2007-05-07 03:57:23 PDT My hosting site requires that MySQL usernames are in the format web80-name. This causes problems once I've logged in as admin as the SQL is invalid e.g. Error in query: SELECT web80-xxxman.user.username FROM web80-xxxman.user WHERE web80-xxxman.user.id = 1You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '-xxxman.user WHERE web80-xxxman.user.id = 1' at line 1 Any ideas how to get around this problem? James. jonathanwminer 2007-05-07 04:42:03 PDT James - I think the root of your problem is that I believe ODM currently does not support table name prefixes. It would be simple to fix, but would require that EVERY database query gets changed. Like this, using rough PHP syntax: "SELECT * from user" needs to be changed to: "SELECT * from " . $prefix . "user" In your case, $prefix would be set to "web80-" The second problem, which causes the syntax error you reported above is that you have two dots "." in the name. As far as I know, there is only a single dot, separating the table name from the field name. Valid: web80-user.username Invalid: web80.user.username Hope this helps. If there isn't already a feature request for table name prefixes, you might consider adding one. jltgordon 2007-05-07 04:55:51 PDT No this problem is that ODM create SQL like "SELECT schema.table.column from schema.table". Where the schema includes a hyphen MySQL gets upset. I have managed to get around the problem by setting the following in the config.php... $GLOBALS['database'] = '`web80-xxxman`'; // Enter the name of the database here $db = mysql_select_db('web80-xxxman', $GLOBALS['connection']); This allow the select_db to run properly and when ODM creates it's SQL it uses the $GLOBAL['database'] which then produces correct SQL like SELECT `web80-xxxman`.user.username FROM `web80-xxxman`.users WHERE .... James. logart 2007-05-07 07:49:26 PDT Funny, I was just going to suggest that. |