By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,747 Members | 2,011 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,747 IT Pros & Developers. It's quick & easy.

[PDO] Displaying output from prepare()?

P: n/a
Hello

I use the prepare/execute combo to generate SQL statements. Is it
possible to actually see what PDO creates with prepare()?

=======
$sql = "INSERT INTO mytable (id, label) VALUES (NULL,?)";
$insert = $dbh->prepare($sql);

//Display SQL before running it

$insert->execute(array($argv[1]));
=======

Thank you.
Oct 7 '08 #1
Share this Question
Share on Google+
5 Replies


P: n/a
Gilles Ganault wrote:
Hello

I use the prepare/execute combo to generate SQL statements. Is it
possible to actually see what PDO creates with prepare()?

=======
$sql = "INSERT INTO mytable (id, label) VALUES (NULL,?)";
$insert = $dbh->prepare($sql);

//Display SQL before running it

$insert->execute(array($argv[1]));
=======

Thank you.
Unfortunately not.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================

Oct 7 '08 #2

P: n/a

Gilles Ganault schreef:
Hello

I use the prepare/execute combo to generate SQL statements. Is it
possible to actually see what PDO creates with prepare()?

=======
$sql = "INSERT INTO mytable (id, label) VALUES (NULL,?)";
$insert = $dbh->prepare($sql);

//Display SQL before running it

$insert->execute(array($argv[1]));
=======

Thank you.
Hi Gilles,

As far as I know: No.
However, if you are on a bughunt, you can probably ask your database
itself to log anything that is executed against it in a logfile.

Regards,
Erwin Moller

--
============================
Erwin Moller
Now dropping all postings from googlegroups.
Why? http://improve-usenet.org/
============================
Oct 7 '08 #3

P: n/a
Gilles Ganault escribió:
I use the prepare/execute combo to generate SQL statements. Is it
possible to actually see what PDO creates with prepare()?
I guess you want to see the SQL query with the value of your parameters,
something like: INSERT INTO mytable (id, label) VALUES (NULL,'Foo Bar')

I suppose these internals depend on the driver but I'd dare say that
"INSERT INTO mytable (id, label) VALUES (NULL,?)" is what's actually
sent to the database server, with the values being sent separately.

--
-- http://alvaro.es - Álvaro G. Vicario - Burgos, Spain
-- Mi sitio sobre programación web: http://bits.demogracia.com
-- Mi web de humor al baño María: http://www.demogracia.com
--
Oct 7 '08 #4

P: n/a
On Tue, 07 Oct 2008 12:17:14 -0400, Jerry Stuckle
<js*******@attglobal.netwrote:
>Unfortunately not.
Too bad. Thanks guys.
Oct 7 '08 #5

P: n/a
..oO(Gilles Ganault)
>I use the prepare/execute combo to generate SQL statements. Is it
possible to actually see what PDO creates with prepare()?
See <news:em************@ophelia.g5n.co.uk>.

Micha
Oct 8 '08 #6

This discussion thread is closed

Replies have been disabled for this discussion.