Say, this is my query
$stmt = "SELECT * FROM foo WHERE x=?";
How do I print the above query plus the bound parameter to the screen or to a file in PHP?
When I print $stmt it says:
mysqli_stmt could not be converted to string
Here’s my code:
if ($stmt = $this->conn->prepare($query)) {
$stmt ->bind_param('ss', $un, $pwd);
logToFile ("my.log", "inside mysql\n");
logToFile ("my.log", $stmt);
You can log your PHP variable
$querywhich contains the SQL query with parameter placeholders.But you probably want to log the query combined with the parameter values. This is a very common request, but this information is not exposed through the client library, so you can’t read it from PHP.
You can get the query combined with the parameter values in the MySQL General Query Log, as you
execute()the query.