Home > Backend Development > PHP Tutorial > Example of using the database tracker of zf framework_PHP tutorial

Example of using the database tracker of zf framework_PHP tutorial

WBOY
Release: 2016-07-13 10:35:58
Original
792 people have browsed it

Call the tracker method

Copy the code The code is as follows:

$Profiler = $Db -> getProfiler( );

Copy code The code is as follows:

/*
How to use the tracker
*/

//Introduce the Loader class (automatic loading class)
require_once("Zend/Loader.php");
//Use the Loader class to introduce a Db class
Zend_Loader::loadClass("Zend_Db" ; .0.1' ,
'username' => 'root' ,
'password' => '111' ,
'dbname' => 'test',
'profiler' = > "true"
);
//Tell the database and database configuration information operated by the Zend_Db class
$Db = Zend_Db::factory('PDO_Mysql', $Config);
// Execute the encoding statement
$Db -> query("set names utf8");
//------------------------ ----------------------------
$Sql = "select * from gongsi";
$Db -> query ($Sql);
//Call the tracker method
$Profiler = $Db -> getProfiler();
//Get the number of submitted statements
echo "The number of submissions :" . $Profiler -> getTotalNumQueries() . "
";
//Get SQL statement execution information
$Result = $Profiler -> getQueryProfiles();
foreach ( $Result as $key => $value)
{
//Output the executed statement
echo "The text content is: " . $value->getQuery() . "
";
//Output the time it takes to run the statement
echo "The time spent is:" . $value->getElapsedSecs() . "
";
}
// Output the total time spent on all statements
echo "The total time spent is:" . $Profiler -> getTotalElapsedSecs();
?>




http://www.bkjia.com/PHPjc/741261.html

www.bkjia.com

http: //www.bkjia.com/PHPjc/741261.htmlTechArticleThe method of calling the tracker is as follows: $Profiler = $Db - getProfiler(); The copy code is as follows: : ?php /* How to use the tracker*/ //Introduce the Loader class (automatic loading class...
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template