We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 15629
    • 21 Posts
    I was looking at the API tonight for the first time and something struck me. I see a "disconnect()" method and thought, that’s not very efficient. Maybe I am wrong because I haven’t looked at the core code yet however, why is there not a __destroy() method? Having the DB disconnection code within the __destroy() method would close the connection as soon as the script is done processing. No room for human error there.

    Is this for the intent of backwards compatibility with older versions of PHP installs?
    • If you are coming to MODx for the first time, you should look at Revolution. The database system in Evolution is deprecated in Revolution, which now uses xPDO (a lightweight O/RM wrapper for PDO). You can safely ignore the disconnect method as the connection is closed when the script stops executing anyway. But yes, Evolution must maintain backwards compatibility with older PHP systems. If you want to discuss database classes and design patterns though, definitely take a look at xPDO and MODx Revolution which is built on top of it.