To create a new connection to my database, i use :
$dbh = new PDO("mysql:host=$hostname;dbname=nameofdatabase", $username, $password);
I am almost sure there is a faster way to do it without having to provide username, password etc.
Could anyone assist?
Yes, tried searching for it but i am out of luck.
MODx maintains a connection to the database. You shouldn’t need to create a connection unless you want to use another database. The method depends on the version of MODx.
Im using revolution. So what u are saying is that i need only to query? Any hinters on how to do that directly? Is that something like modx->?
And no i am not using xpdo and shemas..
Sorted.
For anyone else wondering:
$modx->query($sql)
Actually, in Revolution, you might want to consider using xPDO. It’s very simple once you get used to it:
Here’s a start:
http://bobsguides.com/revolution-objects.html