PHP Classes

File: example.php

Recommend this page to a friend!
  Classes of Jay Gilford  >  Simple timer class  >  example.php  >  Download  
File: example.php
Role: Example script
Content type: text/plain
Description: Example usage
Class: Simple timer class
Measure the time that elapses
Author: By
Last change:
Date: 6 years ago
Size: 828 bytes


Class file image Download

include 'timer.class.php';
$db_timer = new timer();
// Connect to database here and create the query to be run
mysql_connect('localhost', 'root', '');
$query = "SELECT * FROM table";
// Start timer before executing query
$result = mysql_query($query);
// Pause timer
// Echo out the selected data
while($row = mysql_fetch_assoc($result)) {
print_r($row, true);
// Create another query
$query = "SELECT * FROM table2";
// Unpause the timer
// Execute the query
$result = mysql_query($query);
// Stop the timer and get the total execution time
$total_time = $db_timer->stop();
// Display details
echo 'SQL queries took '.$total_time.' seconds to execute in total';