Zend Framework Zend Db Profiler
Janeiro 12, 2012 Deixe um comentário
Analyzing database SQL query’s within Zend Framework Front Controllers isn’t difficult here’s an example:
$bootstrap = $this->getFrontController()->getParam(“bootstrap”);
if ($bootstrap->hasPluginResource(“db”)) {
$dbResource = $bootstrap->getPluginResource(“db”);
$db = $dbResource->getDbAdapter();
$profiler = $db->getProfiler();
$profiler->setEnabled(true);
}
foreach ($devs->getDevices($cliente->idcliente) as $equip) {
$equip->findDependentRowset(“DM_Model_Services”, “equipment”);
$query = $profiler->getLastQueryProfile();
echo $query->getQuery();
}
My database config in application.ini:
resources.db.adapter = pdo_mysql
resources.db.params.host = 127.0.0.1
resources.db.params.username = user
resources.db.params.password = pass
resources.db.params.dbname = sal_db
This will give an output like:
SELECT `service`.* FROM `service` WHERE (`idequipment` = 70)