We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 22303 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...
      • 1764
      • 680 Posts
      Yes! Let’s get this fixed. Two database select calls are one two many. There’s database selection shouldn’t happen automatically.
        • 22303 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.
          • 1764
          • 680 Posts
          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.
            • 32963
            • 1,732 Posts
            Hmmm,

            True but remember that inside MODx there might be times when a snippet, plugin or module might change the current database.
              xWisdom
              www.xwisdomhtml.com
              The fear of the Lord is the beginning of wisdom:
              MODx Co-Founder - Create and do more with less.
              • 22303 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.
                • 32963
                • 1,732 Posts
                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
                  xWisdom
                  www.xwisdomhtml.com
                  The fear of the Lord is the beginning of wisdom:
                  MODx Co-Founder - Create and do more with less.