bjyoungblood/BjyProfiler — pull request #1 by adamlundrigan (2012-07-06 15:27:39+00:00)
Title: Profiling Prepared Statements

Currently, BjyProfiler does not detect prepared statements, as those don't use the Adapter's query method. I've added an extension of the `Statement` class for each `Zend\Db\Adapter\Driver` bundled with ZF2, and a method on the `ProfilingAdapter` to inject the correct `ProfilingStatement` class into the driver.

Usage:
```
'changeme',
'username' => 'changeme',
'password' => 'changeme',
'hostname' => 'localhost'
);

return array(
'service_manager' => array(
'factories' => array(
'Zend\Db\Adapter\Adapter' => function ($sm) use ($dbParams) {
$adapter = new BjyProfiler\Db\Adapter\ProfilingAdapter(array(
'driver' => 'pdo',
'dsn' => 'mysql:dbname='.$dbParams['database'].';host='.$dbParams['hostname'],
'database' => $dbParams['database'],
'username' => $dbParams['username'],
'password' => $dbParams['password'],
'hostname' => $dbParams['hostname'],
));

$adapter->setProfiler(new BjyProfiler\Db\Profiler\Profiler);
// Added this line:
$adapter->injectProfilingStatementPrototype();
return $adapter;
},
),
),
);
```

There may be a better way to register the statement prototype than this, but it has to be done after the profiler is injected into the Adapter, so it can't be done during Adapter instantiation (ie: by overriding Adapter::createDriverFromParameters)