Viewing the 'end' SQL for prepared statements

ORMs such as Doctrine and database API's like PDO or MySQLi offer prepared statements which provide stronger security for your queries. Unfortunately they can be harder to debug as it's difficult to see the 'end' sql that's actually being sent to the database. There's no way to achive this server side with PHP however there is a quick way to view what's going on behind the scenes without installing any extra software...

Open up your my.ini file (depending on server software this will be somewhere like C:\xampp\mysql\bin) and find the [mysqld] section. Add a line at the bottom like the following defining an appropriate path to write to:




Restart  MySQL and you'll now see that your queries are all getting logged to the text file. A word of caution, this file can get pretty big pretty quickly so it's advised to swtich this off again when you're done testing...

Sign Up
comments powered by Disqus

Popular Tags

Need a web developer?

If you'd like to work with code synthesis on your next project get in touch via the contact page.