Suppose you're working with Doctrine and have meticulously crafted a query like this:
$q = Doctrine_Query::create()->select('id')->from('MyTable');
Now, as you fine-tune your query with conditions, such as:
$q->where('normalisedname = ? OR name = ?', array($string, $originalString));
You're eager to examine the raw SQL before execution. So, you call:
$q->getSQLQuery();
But alas, it's not what you expected - it's a prepared statement with question marks. You want to see what will be sent to the database.
Well, here's the truth: Doctrine doesn't send "real" SQL to the database server. It uses prepared statements, a three-step process:
This means there's never a "real" SQL query on the PHP side - so, Doctrine can't display it.
The above is the detailed content of How Can I See the \'Real\' SQL Query in Doctrine When It Uses Prepared Statements?. For more information, please follow other related articles on the PHP Chinese website!