<?php
require_once 'PHP Profiler/profiler.php';
$profile = new profiler;
$point_1 = $profile->start_profile( 'Script Includes' );
include 'objSQL_3.5.2/objSQL.php';
$profile->stop_profile( $point_1 );
$point_2 = $profile->start_profile( 'DB Connection' );
$dbh = new objsql( array( 'sqlite', '', '', '', 'G:\www\dev\Projects\mojotest2.sq3' ) );
if ( error_get_last() !== null )
throw new Exception( error_get_last()['message'] );
else
echo "objSQL Version: {$dbh->obj_info()['OBJSQL_VERSION']}<br />
Database: {$dbh->obj_info()['DATABASE_NAME']}<br />
Driver: {$dbh->obj_info()['DATABASE_DRIVER']}<br />
DB Type: {$dbh->obj_info()['DATABASE_TYPE']}<br />
Version: {$dbh->obj_info()['DATABASE_VERSION']}<br />
Collation: {$dbh->obj_info()['DATABASE_CHARSET']}<br />
PHP Version: {$dbh->obj_info()['PHP_VERSION']}<br /><hr />";
$profile->stop_profile( $point_2 );
$point_3 = $profile->start_profile( 'Insert Query' );
for ( $i = 1; $i < 41; $i++ )
{
$data = array( 'f_name' => 'Bob',
'l_name' => 'Jones' );
$rs = $dbh->obj_insert( 'emp_test', $data );
if ( $dbh->obj_error() )
throw new Exception( $dbh->obj_error_message() );
$data = array( 'f_name' => 'Helen',
'l_name' => 'Xavier' );
$rs = $dbh->obj_insert( 'emp_test', $data );
if ( $dbh->obj_error() )
throw new Exception( $dbh->obj_error_message() );
$data = array( 'f_name' => 'Ken',
'l_name' => 'Gomez' );
$rs = $dbh->obj_insert( 'emp_test', $data );
if ( $dbh->obj_error() )
throw new Exception( $dbh->obj_error_message() );
$data = array( 'f_name' => 'Patty',
'l_name' => 'Cline' );
$rs = $dbh->obj_insert( 'emp_test', $data );
if ( $dbh->obj_error() )
throw new Exception( $dbh->obj_error_message() );
}
$profile->stop_profile( $point_3 );
$point_4 = $profile->start_profile( 'Select Query' );
$rs = $dbh->obj_select( 'emp_test', '', 'emp_id' );
if ( $dbh->obj_error() )
throw new Exception( $dbh->obj_error_message() );
while ( $rs->obj_fetch_assoc() )
{
echo "{$rs->obj_field( 'emp_id' )} -
{$rs->obj_field( 'f_name' )} -
{$rs->obj_field( 'l_name' )}<br />";
}
$rs->obj_free_result();
$profile->stop_profile( $point_4 );
//save to log file
$profile->print_profile( 'profile_log.txt' );
//print to screen
echo "<pre>{$profile->print_profile()}</pre>";
?>
|