How to use ZF framework database tracker

WBOY
Release: 2016-07-25 08:48:39
Original
963 people have browsed it
Learning assignment Zend_Db uses
//Method to call the tracker
$Profiler = $Db -> getProfiler();
  1. /*
  2. How to use the tracker
  3. */
  4. //Introduce the Loader class (automatic loading class)
  5. require_once("Zend/Loader.php");
  6. //Use the Loader class Introduce a Db class
  7. Zend_Loader::loadClass("Zend_Db");
  8. //Introduce Zend_Db's stater
  9. Zend_Loader::loadClass("Zend_Db_Statement_Pdo");
  10. //Configure database connection information
  11. $Config = array('host' " true"
  12. );
  13. //Tell the Zend_Db class to operate the database and database configuration information
  14. $Db = Zend_Db::factory('PDO_Mysql', $Config);
  15. //Execute the encoding statement
  16. $Db -> query( "set names utf8");
  17. //---------------------------------------- -------------
  18. $Sql = "select * from gongsi";
  19. $Db -> query($Sql);
  20. //Method to call the tracker
  21. $Profiler = $Db -> getProfiler();
  22. //Get the number of submitted statements
  23. echo "Number of submissions:" . $Profiler -> getTotalNumQueries() . "
    ";
  24. //Get the number of SQL statements executed Information
  25. $Result = $Profiler -> getQueryProfiles();
  26. foreach ($Result as $key => $value)
  27. {
  28. //Output the executed statement
  29. echo "The text content is:" . $value- >getQuery() . "
    ";
  30. //Output the time it takes to run the statement
  31. echo "The time spent is:" . $value->getElapsedSecs() . "
    ";
  32. }
  33. //Output the total time spent on all statements
  34. echo "The total time spent is:" . $Profiler -> getTotalElapsedSecs();
  35. ?>
  36. Copy code
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
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!