-
☆ A M B ☆
- 450 Posts
I’ve been meaning to ask this for a while. Often times I know what my query statement would look like if I were writing it in straight mySQL... but I’m not entirely certain that I’m building an xPDOQuery object that is equivalent and doing what I want it to. If there was a way to get the equivalent mySQL query from an xPDOQuery object... that would be extremely helpful for debugging. Is there a way to do that?
Without looking I think ther’s an sql() method that returns the actual sql string thats going to go to the database, you see its usage in log output statements.
Use MODx, or the cat gets it!
-
MODX Staff
- 730 Posts
It’s the ->toSQL() method. From docs: "Converts the current xPDOQuery to parsed SQL".
$Q = $xpdo->newQuery('People');
$Q->where(array('floating_in_space'=> 1));
$sql = $Q->toSQL();