Skip to content
This repository has been archived by the owner on Jan 8, 2021. It is now read-only.

Commit

Permalink
Merge pull request #19 from katalonec/mysqli_buffer
Browse files Browse the repository at this point in the history
Mysqli buffer option
  • Loading branch information
bjyoungblood committed Jan 10, 2013
2 parents 6f4f4d6 + bac0219 commit b4b37f8
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 5 deletions.
11 changes: 9 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@ $dbParams = array(
'database' => 'changeme',
'username' => 'changeme',
'password' => 'changeme',
'hostname' => 'localhost'
'hostname' => 'localhost',
// buffer_results - only for mysqli buffered queries, skip for others
'options' => array('buffer_results' => true)
);

return array(
Expand All @@ -40,7 +42,12 @@ return array(
));

$adapter->setProfiler(new BjyProfiler\Db\Profiler\Profiler);
$adapter->injectProfilingStatementPrototype();
if (isset($dbParams['options']) && is_array($dbParams['options'])) {
$options = $dbParams['options'];
} else {
$options = array();
}
$adapter->injectProfilingStatementPrototype($options);
return $adapter;
},
),
Expand Down
7 changes: 6 additions & 1 deletion config/module.config.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,12 @@
if(class_exists('BjyProfiler\Db\Adapter\ProfilingAdapter')){
$adapter = new BjyProfiler\Db\Adapter\ProfilingAdapter($config['db']);
$adapter->setProfiler(new BjyProfiler\Db\Profiler\Profiler);
$adapter->injectProfilingStatementPrototype();
if (isset($config['db']['options']) && is_array($config['db']['options'])) {
$options = $config['db']['options'];
} else {
$options = array();
}
$adapter->injectProfilingStatementPrototype($options);
} else {
$adapter = new Zend\Db\Adapter\Adapter($config['db']);
}
Expand Down
7 changes: 5 additions & 2 deletions src/BjyProfiler/Db/Adapter/ProfilingAdapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public function getProfiler()
}


public function injectProfilingStatementPrototype()
public function injectProfilingStatementPrototype(array $options = array())
{
$profiler = $this->getProfiler();
if (!$profiler instanceof Profiler) {
Expand All @@ -33,7 +33,10 @@ public function injectProfilingStatementPrototype()
$driverName = get_class($driver);
switch ($driverName) {
case 'Zend\Db\Adapter\Driver\Mysqli\Mysqli':
$statementPrototype = new Driver\Mysqli\ProfilingStatement();
$defaults = array('buffer_results' => false);
$options = array_intersect_key(array_merge($defaults, $options), $defaults);

$statementPrototype = new Driver\Mysqli\ProfilingStatement($options['buffer_results']);
break;
case 'Zend\Db\Adapter\Driver\Sqlsrv\Sqlsrv':
$statementPrototype = new Driver\Sqlsrv\ProfilingStatement();
Expand Down

0 comments on commit b4b37f8

Please sign in to comment.