Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a way to see a prepared query as it will be executed on the database? [duplicate]

Tags:

php

mysql

mysqli

Possible Duplicate:
PDO Prepared Statements

I'm using the mysqli extension in PHP and I'm wondering, is there possibly any way to see a prepared query as it will be executed on the server, e.g. The query is something like this

select * from table1 where id = ? and name = ?

but I want to see the query after the values are filled in, like this:

select * from table1 where id = 20 and name = "John"
like image 273
pilsetnieks Avatar asked Nov 20 '08 12:11

pilsetnieks


People also ask

What is PREPARE Stmt mysql?

PREPARE stmt_name FROM preparable_stmt. The PREPARE statement prepares a SQL statement and assigns it a name, stmt_name , by which to refer to the statement later. The prepared statement is executed with EXECUTE and released with DEALLOCATE PREPARE .

What are prepared statements in SQL?

A prepared statement is a feature used to execute the same (or similar) SQL statements repeatedly with high efficiency. Prepared statements basically work like this: Prepare: An SQL statement template is created and sent to the database. Certain values are left unspecified, called parameters (labeled "?").


1 Answers

Turn on mysql query logging and it will log all queries to a text file for you to review.

like image 159
DreamWerx Avatar answered Oct 20 '22 11:10

DreamWerx