Commit 982e009a authored by Taylor Otwell's avatar Taylor Otwell

added query event for hooking into database for logging.

parent 96b43e90
<?php namespace Laravel\Database; use PDO, PDOStatement;
<?php namespace Laravel\Database; use PDO, PDOStatement, Laravel\Event;
class Connection {
......@@ -222,7 +222,7 @@ class Connection {
// execution time in a static array that is accessed by all of
// the connections used by the application. This allows us to
// review all of the executed SQL.
static::$queries[] = compact('sql', 'bindings', 'time');
static::log($sql, $bindings, $time);
return array($statement, $result);
}
......@@ -260,6 +260,21 @@ class Connection {
return trim($sql);
}
/**
* Log the query and fire the core query event.
*
* @param string $sql
* @param array $bindings
* @param int $time
* @return void
*/
protected static function log($sql, $bindings, $time)
{
Event::fire('laravel: query', array($sql, $bindings, $time));
static::$queries = compact('sql', 'bindings', 'time');
}
/**
* Get the driver name for the database connection.
*
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment