The ZF Framework database tracker uses the example _php instance

Source: Internet
Author: User

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 ();
?>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.