-
MODX Staff
- 10,725 Posts
Alright, we’ve apparently stripped the `` from the database name in places other than the code that selects the database. This is incorrect, and will fail when database names contain any kind of non-alphanumeric character or reserved words. In all actuality, once the database is selected, we should never have to reference the name of the database in the queries again. In other words, the only reason the dbase name was ever included in all the queries in Eto and our previous versions of MODx was because the `` around the dbase name prevented the selection of the database, and so it was required in order to select from tables when no database is selected. Now that we’ve correct the database selection issue by removing the `` from around it, we should never have to reference the db name in another query within the system unless we are retrieving data from another database container.
A quick fix, until we can address this in every query in MODx is to only remove the `` from the database name when calling the function to select the db...
Yes! Let’s get this fixed. Two database select calls are one two many. There’s database selection shouldn’t happen automatically.
-
MODX Staff
- 10,725 Posts
Actually, there’s only one database select call, when you make the connection, but because that didn’t work before (you can’t select a database name surrounded by `` in the php mysql_select_db() function) we had to use $dbase.$prefix.’table_name’ for any queries to work within MODx, cause no database was ever selected and no error thrown. When working inside a selected database container, you shouldn’t have to reference the dbase name on every table reference.
Must have been fixed since the last time I messad around with it. But I remmeber battling with that for a long time before realizing that the backticks were throwing it off.
Hmmm,
True but remember that inside MODx there might be times when a snippet, plugin or module might change the current database.
-
MODX Staff
- 10,725 Posts
The current database should never be changed inside the parser; that’s what new instances of the DBAPI would be for, correct? Or at least, that’s when you would specify a different database in the query. But you should still be able to assume you are in the database container configured for the site when executing inside that site.
When a new instance of the DBAPI is created and the user specifies a different database then I think php will change the current db from MODx to some other