add database.profile config option.

This commit is contained in:
Taylor Otwell
2012-02-16 08:46:48 -06:00
parent b29f8a88fe
commit 36834c1118
2 changed files with 19 additions and 2 deletions

View File

@@ -2,6 +2,20 @@
return array(
/*
|--------------------------------------------------------------------------
| Database Query Logging
|--------------------------------------------------------------------------
|
| By default, the SQL, bindings, and execution time are logged in an array
| for you to review. They can be retrieved via the DB::profile() method.
| However, in some situations, you may want to disable logging for
| ultra high-volume database work. You can do so here.
|
*/
'profile' => true,
/*
|--------------------------------------------------------------------------
| Default Database Connection

View File

@@ -1,4 +1,4 @@
<?php namespace Laravel\Database; use PDO, PDOStatement, Laravel\Event;
<?php namespace Laravel\Database; use PDO, PDOStatement, Laravel\Config, Laravel\Event;
class Connection {
@@ -222,7 +222,10 @@ class Connection {
// Once we have execute the query, we log the SQL, bindings, and
// execution time in a static array that is accessed by all of
// the connections used by the application.
$this->log($sql, $bindings, $time);
if (Config::get('database.profile'))
{
$this->log($sql, $bindings, $time);
}
return array($statement, $result);
}