Created
April 2, 2012 12:35
-
-
Save jpadilla/2283142 to your computer and use it in GitHub Desktop.
Doctrine 2 Logger for CodeIgniter's Profiler
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace Doctrine\DBAL\Logging; | |
class Profiler implements SQLLogger | |
{ | |
public $start = null; | |
private $ci; | |
public function __construct() | |
{ | |
$this->ci =& get_instance(); | |
} | |
/** | |
* {@inheritdoc} | |
*/ | |
public function startQuery($sql, array $params = null, array $types = null) | |
{ | |
$this->start = microtime(true); | |
$this->ci->db->queries[] = "/* doctrine */ \n".$sql; | |
} | |
/** | |
* {@inheritdoc} | |
*/ | |
public function stopQuery() | |
{ | |
$this->ci->db->query_times[] = microtime(true) - $this->start; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Smart cookie. Maybe do this instead on startQuery so that you can get the query parameters shown instead of question marks