-----BEGIN PGP SIGNED MESSAGE----- Hash: RIPEMD160
> I need to log every INSERT, UPDATE and DELETE queries even when using > placeholders. Here some code: > > $sql = "UPDATE users SET `name`=? WHERE d`=1;"; > $sth = $dbh->prepare($sql); > $sth->execute('Test User'); > $sth->finish(); > > Of course execute params are given dynamically and I want to use > placeholders for more secure code. > I want to save that UPDATE query into file or database ( I'll prefer > DB :) ) for tracking purposes. Any idea how to do this? The canonical way is to use the named tracing level 'SQL', like so: $dbh->trace('SQL'); However, it's not supported on all DBDs yet (actually, DBD::Pg may be the only one, but I'm not sure). From your non-standard use of backticks above, I presume you are using DBD::mysql, which, from a quick glance at the code, does not support 'SQL' tracing yet. Another option may be to simply set a high numeric trace level: the queries will be logged, albeit surrounded by a lot of noise (but parsing such things out is one of the things Perl is good at, right?). You can also log such queries from the database itself, of course (e.g. the db logs) DBIx::Log4perl may work too, but it doesn't seem to mark the executes in any way that tracks back to the statement that prepared them. - -- Greg Sabino Mullane [EMAIL PROTECTED] PGP Key: 0x14964AC8 200804151151 http://biglumber.com/x/web?pk=2529DF6AB8F79407E94445B4BC9B906714964AC8 -----BEGIN PGP SIGNATURE----- iEYEAREDAAYFAkgEz9YACgkQvJuQZxSWSsjl2ACgjbVeslZkMSJOS59b2HEKlYgi OpEAoK6diZVTB2c2xj7rr6mIpeDn7vuC =0WF3 -----END PGP SIGNATURE-----