<?
class Script_Timer
{
   function Script_Timer ()
   {
       return true;
   }
   
   function Start_Timer ()
   {
       define ("TIMER_START_TIME", microtime());
       
       return true;
   }
   
 function Get_Time ($decimals=2)
   {
       // $decimals will set the number of decimals you want for your milliseconds.

       // format start time
       $start_time = explode (" ", TIMER_START_TIME);
       $start_time = $start_time[1] + $start_time[0];
       // get and format end time
       $end_time = explode (" ", microtime());
       $end_time = $end_time[1] + $end_time[0];
       
       return number_format ($end_time - $start_time, $decimals);
   }
}

function insert($pairs,$table) { // method for inserting record to the database 
    $SQL="INSERT INTO $table ("; 
    $first=true; 
    foreach ($pairs as $key=>$value) { 
        if ($key!="id" || $key!="title" || $key!="submit") { // everything except record ID,title,submit 
        if ($first)  { 
            $value="\"".$value; 
            $first=false; 
        }else { 
            $key=",".$key; 
            $value=",\"".$value; 
        } 
        $fields.=$key; 
        $values.=$value."\""; 
        } 
    } 
    $SQL.=$fields.") VALUES(".$values.")"; 
    // Your database code here ... 
    return $SQL;
    } 

    function update($pairs,$table) { // method for updating records in the database 
    $SQL="UPDATE $table SET "; 
    $first=true; 
    foreach ($pairs as $key=>$value) { 
        if ($key!="id" || $key!="title" || $key!="submit") { // everything except record ID,title,submit 
        if ($first)  { 
            $SQL.="$key=\"$value\""; 
            $first=false; 
        }else { 
            $SQL.=",$key=\"$value\""; 
        } 
        } 
    } 
    $SQL.=" WHERE id=$pairs[id]"; 
    // Your database code here ... 
    } 

    function delete($id,$table) { // method for deleting record from a table 
    $SQL="DELETE FROM $table WHERE id=$id"; 
    $db->query($SQL); 
    // Your database code here ... 
    } 
 
 	

?>