Doctrine orm Codeigniter中的评测原则2.0
当条令2.0集成到codeigniter中时,什么是分析条令查询的好方法 使用通常的CI探查器不知道如何执行查询,因为它使用的是条令,而不是本机活动记录 e、 g.添加此代码时$this->output->enable_profiler(TRUE)它还应该显示执行的查询Doctrine orm Codeigniter中的评测原则2.0,doctrine-orm,profiler,codeigniter-2,Doctrine Orm,Profiler,Codeigniter 2,当条令2.0集成到codeigniter中时,什么是分析条令查询的好方法 使用通常的CI探查器不知道如何执行查询,因为它使用的是条令,而不是本机活动记录 e、 g.添加此代码时$this->output->enable_profiler(TRUE)它还应该显示执行的查询 您可以在条令包中添加探查器 namespace Doctrine\DBAL\Logging; class Profiler implements SQLLogger { public $start = null;
您可以在条令包中添加探查器
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;
}
}
然后将分析器作为记录器加载到您的主条令库中(对于我来说是doctor.php)
并且正常的分析工作正常。与CodeIgniter兼容。。
太好了,非常感谢。正是我要找的!
$logger = new \Doctrine\DBAL\Logging\Profiler;
$config->setSQLLogger($logger);