The ZF Framework Database Tracker Usage Example

Source: Internet
Author: User
Tags config

  This article mainly introduces the ZF Framework database tracker Use example, now the use of the tracker to share to everyone, need friends can refer to the following

The method to invoke the tracker     code is as follows: $Profiler = $Db-> getprofiler ();     Code as follows: <?php/* Tracker Use Method */ //Introduce Loader Class (Automatic loading Class) require_once ("zend/loader.php"); Use the Loader class to introduce a Db class Zend_loader::loadclass ("zend_db"); Introducing the ZEND_DB state-Zend_loader::loadclass ("Zend_db_statement_pdo"); Configure database connection Information $Config = Array (' Host ' => ' 127.0.0.1 ',     ' username ' => ' root ',      ' Passwo Rd ' => ',      ' dbname ' => ' test ',     ' Profiler ' => ' true '    ; Tells the database and database configuration information that the zend_db class operates $Db = Zend_db::factory (' Pdo_mysql ', $Config); //EXECUTE encoded statements   $Db-> query ("Set Names UTF8 "); -----------------------------------------------------$SQL = "SELECT * from Gongsi"; $Db-> Query ($SQL); The method of calling the tracker $Profiler = $Db-> getprofiler (); Gets the number of Count echo "submissions for the submission statement:". $Profiler-> gettotalnumqueries (). "<br>"; Gets the information executed by the SQL statement $Result = $Profiler-> getqueryprofiles (); foreach ($Result as $key => $value)   { //output runs the statement  echo "text is:". $value->getquery (). "<br>";  //the time it takes for the output to run the statement  echo "time spent:". $value->getelapsedsecs (). "<br>"; The total time that was spent in outputting all statements echo "The total time spent 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.