Skip to content

Commit

Permalink
alternative: \dibi
Browse files Browse the repository at this point in the history
  • Loading branch information
dg committed Oct 8, 2015
1 parent b581513 commit bc5064c
Show file tree
Hide file tree
Showing 9 changed files with 90 additions and 93 deletions.
4 changes: 2 additions & 2 deletions src/Dibi/Bridges/Nette/Panel.php
Expand Up @@ -107,13 +107,13 @@ public function getPanel()
$explain = NULL; // EXPLAIN is called here to work SELECT FOUND_ROWS()
if ($this->explain && $event->type === Event::SELECT) {
try {
$backup = [$event->connection->onEvent, Dibi\Dibi::$numOfQueries, Dibi\Dibi::$totalTime];
$backup = [$event->connection->onEvent, \dibi::$numOfQueries, \dibi::$totalTime];
$event->connection->onEvent = NULL;
$cmd = is_string($this->explain) ? $this->explain : ($event->connection->getConfig('driver') === 'oracle' ? 'EXPLAIN PLAN FOR' : 'EXPLAIN');
$explain = Helpers::dump($event->connection->nativeQuery("$cmd $event->sql"), TRUE);
} catch (Dibi\Exception $e) {
}
list($event->connection->onEvent, Dibi\Dibi::$numOfQueries, Dibi\Dibi::$totalTime) = $backup;
list($event->connection->onEvent, \dibi::$numOfQueries, \dibi::$totalTime) = $backup;
}

$s .= '<tr><td>' . sprintf('%0.3f', $event->time * 1000);
Expand Down
4 changes: 2 additions & 2 deletions src/Dibi/Bridges/Tracy/Panel.php
Expand Up @@ -107,13 +107,13 @@ public function getPanel()
$explain = NULL; // EXPLAIN is called here to work SELECT FOUND_ROWS()
if ($this->explain && $event->type === Event::SELECT) {
try {
$backup = [$event->connection->onEvent, Dibi\Dibi::$numOfQueries, Dibi\Dibi::$totalTime];
$backup = [$event->connection->onEvent, \dibi::$numOfQueries, \dibi::$totalTime];
$event->connection->onEvent = NULL;
$cmd = is_string($this->explain) ? $this->explain : ($event->connection->getConfig('driver') === 'oracle' ? 'EXPLAIN PLAN FOR' : 'EXPLAIN');
$explain = Helpers::dump($event->connection->nativeQuery("$cmd $event->sql"), TRUE);
} catch (Dibi\Exception $e) {
}
list($event->connection->onEvent, Dibi\Dibi::$numOfQueries, Dibi\Dibi::$totalTime) = $backup;
list($event->connection->onEvent, \dibi::$numOfQueries, \dibi::$totalTime) = $backup;
}

$s .= '<tr><td>' . sprintf('%0.3f', $event->time * 1000);
Expand Down
4 changes: 2 additions & 2 deletions src/Dibi/Connection.php
Expand Up @@ -76,7 +76,7 @@ public function __construct($config, $name = NULL)
self::alias($config, 'result|formatDateTime', 'resultDateTime');

if (!isset($config['driver'])) {
$config['driver'] = Dibi::$defaultDriver;
$config['driver'] = \dibi::$defaultDriver;
}

$class = $tmp = preg_replace(['#\W#', '#sql#'], ['_', 'Sql'], ucfirst(strtolower($config['driver'])));
Expand Down Expand Up @@ -313,7 +313,7 @@ final public function nativeQuery($sql)
{
$this->connected || $this->connect();

Dibi::$sql = $sql;
\dibi::$sql = $sql;
$event = $this->onEvent ? new Event($this, Event::QUERY, $sql) : NULL;
try {
$res = $this->driver->query($sql);
Expand Down

0 comments on commit bc5064c

Please sign in to comment.