Is it possible to just write an SQL statement in 2.1 without having to create XPDO objects and classes and whatnot?
I miss $modx->db more than words can say.
-
☆ A M B ☆
- 24,524 Posts
At the risk of completely disgusting Jason, I’ll add that of course any time you want to you can use the raw PHP mysql database functions.
Back when a database abstraction layer was being discussed (which led to the dbAPI for Evo), I wanted to use this library, as I had used it before and rather liked it (WordPress uses it).
http://justinvincent.com/ezsql
-
MODX Staff
- 10,725 Posts
You’re not disgusting me Susan, but if you choose to use these functions in Revolution, you will always create two database connections, which is the most expensive part of any PHP request. This simply makes no sense. There is a DBAPI plugin for Revolution if you need it, which will share the connection.
The other benefits of Revo/xPDO will also be useless, such as database result set caching, which is a huge feature for scalability of large sites or when working with external database servers. Future features like master/slave support for write/read operations respectively, will also not be any use if you choose to circumvent the Database Access layer which MODX Revolution is built upon. I won’t even mention supporting multiple database engines with a single codebase.
-
☆ A M B ☆
- 24,524 Posts
Indeed, if I ever do energize myself to get into Revo, it will definitely be mostly because of the elegant power of xPDO. I wasn’t recommending using raw PHP mysql functions, just saying that one could if one really wanted to for some reason. But it’s definitely worth the effort to learn to be comfortable with the xPDO API if you’re working with Revo.
If you’re just querying the MODX tables, xPDO is not all that difficult:
http://bobsguides.com/revolution-objects.html, and it’s definitely worth learning if you’re running Revolution.
If you need to deal with your own DB tables, you can autocreate the xPDO classes and maps:
http://bobsguides.com/custom-db-tables.html and use the same methods on the page above for them.