Hi Masha,

PHP doesn't offer Dtrace probes other then function-entry and function-return 
at the moment. We are currently working on adding additional probes to PHP and 
it's extensions.

The only, and frankly clumsy way, that I'm aware of, is tracing the underlying 
C functions. Depending on the current PHP MySQL extension you are using (either 
PDO-MySQL, MySQLi, MySQL or MySQLND), there are different functions you have to 
trace.

For example if you use the PHP MySQL bindings. A extremely simple PHP script 
would be:
<?php

$conn = mysql_connect("localhost");
mysql_select_db("test");
$res = mysql_query("select username from test");
if (!$res) {
    fprintf(STDERR, mysql_error());
    return -1;
}

while ($row = mysql_fetch_assoc($res)) {
    printf("%s\n", $row['username']);
}
?>

You can then trace the zif_mysql_query function which is the underlying C 
function in PHP. Maybe the most effective way would be to directly trace the 
libmysql call to mysql_real_query().

pid$target::mysql_real_query:entry
{
  trace(copyinstr(arg1));
}

would print the query you are executing. But in case you want to have 
additional information, such as thread_id, etc you have to check how the 
functions and MySQL structs work.

I know that this is kind of tricky, and you have to know the PHP codebase. 
There is no other way I'm aware of at the moment.

--
David Soria Parra - Software Engineer

Sun Microsystems GmbH
Sonnenallee 1
85551 Heimstetten
Germany
www.sun.de
mailto: david.soriaparra at sun.com

Amtsgericht Muenchen: HRB 161028
Geschaeftsfuehrer: Wolfgang Engels, Dr. Roland Boemer, Thomas Schroeder
Vorsitzender des Aufsichtsrates: Martin Haering
-- 
This message posted from opensolaris.org

Reply via email to