Is there any way I can convert a PDO Bound query into a regular string? For example, I have:
$query = "UPDATE reservations SET "
. "user_initials = :user_initials "
. ", user_id = :user_id "
. "WHERE id = :id;";
$db = Database::getDB();
echo $query . '<br>';
$statement = $db->prepare($query);
$test = "";
echo '<br>' . $test . '<br>';
However, I actually have 50+ bound values, and I'm getting an error Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ' trans_paym_loc = 0 , trans_payee_type = D , trans_payee_id = 1 , trans_paym_dat' at line 1' in ...
Whenever I get such an error I usually echo my query, copy it into phpMyAdmin, then I can see clearly what values are causing that problem, and go from there.
My question is, how can I translate this into a normal query, so that I can run it in phpMyAdmin? I have read about PDO::ATTR_EMULATE_PREPARES
, which I am trying at the bottom of my script, but I am not getting anything, so I am not sure how to use it. I have also read about MySQL's query log, but I am not sure how to access it.
Any help will be greatly appreciated.