Ways to call the tracker
Copy Code code as follows:
$Profiler = $Db-> getprofiler ();
Copy Code code as follows:
<?php
/*
How to use the tracker
*/
Introduce loader class (Auto load Class)
Require_once ("zend/loader.php");
Introducing a DB class using the Loader class
Zend_loader::loadclass ("zend_db");
Introducing the zend_db of a State device
Zend_loader::loadclass ("Zend_db_statement_pdo");
Configure Database connection Information
$Config = Array (' Host ' => ' 127.0.0.1 '),
' username ' => ' root ',
' Password ' => ' 111 ',
' dbname ' => ' test ',
' Profiler ' => ' true '
);
Tells the database and database configuration information that the ZEND_DB class operates
$Db = zend_db::factory (' Pdo_mysql ', $Config);
Executing a coded statement
$Db-> Query ("Set names UTF8");
//-----------------------------------------------------
$SQL = "SELECT * from Gongsi";
$Db-> Query ($SQL);
Ways to call the tracker
$Profiler = $Db-> getprofiler ();
Gets the number of lines to commit statements
echo "Number of submissions:". $Profiler-> gettotalnumqueries (). "<br>";
Get information on SQL statement execution
$Result = $Profiler-> getqueryprofiles ();
foreach ($Result as $key => $value)
{
To output a running statement
echo "Text content is:". $value->getquery (). "<br>";
The time it takes to run the statement
echo "Takes time:". $value->getelapsedsecs (). "<br>";
}
Total time spent in outputting all statements
The total time spent by ECHO is:. $Profiler-> gettotalelapsedsecs ();
?>