Like this code?
Show the author your appreciation.
A minimalistic wrapper for SQLite Databases.
<?php
class SQLite
{
public $connection = null ;
function Affected_Rows ()
{
if ( is_resource ( $this -> connection ) === true )
{
return sqlite_changes ( $this -> connection );
}
return false ;
}
function Connect ( $database )
{
if ( is_file ( $database ) === true )
{
$this -> connection = sqlite_open ( $database ) or trigger_error ( sqlite_error_string ( sqlite_last_error ( $this -> connection )), E_USER_ERROR );
if ( is_resource ( $this -> connection ) === true )
{
return true ;
}
}
return false ;
}
function Disconnect ()
{
if ( is_resource ( $this -> connection ) === true )
{
return sqlite_close ( $this -> connection );
}
return false ;
}
function Insert_ID ()
{
if ( is_resource ( $this -> connection ) === true )
{
return sqlite_last_insert_rowid ( $this -> connection );
}
return false ;
}
function Query ( $sql , $type = 'assoc' )
{
if ( is_resource ( $this -> connection ) === true )
{
$query = sqlite_query ( $this -> connection , $sql ) or trigger_error ( sqlite_error_string ( sqlite_last_error ( $this -> connection )), E_USER_WARNING );
if ( is_resource ( $query ) === true )
{
return sqlite_fetch_all ( $query , constant ( 'SQLITE_' . strtoupper ( $type )));
}
if ( $query === true )
{
switch ( strtoupper ( substr ( trim ( $sql ), 0 , strpos ( trim ( $sql ), ' ' ))))
{
case 'INSERT' :
return $this -> Insert_ID ();
break;
case 'UPDATE' :
case 'REPLACE' :
case 'DELETE' :
return $this -> Affected_Rows ();
break;
}
return true ;
}
}
return false ;
}
function Quote ( $string )
{
if ( get_magic_quotes_gpc () === true )
{
$string = stripslashes ( $string );
}
return '\'' . sqlite_escape_string ( trim ( $string )) . '\'' ;
}
function Tick ( $string )
{
$string = explode ( '.' , str_replace (array( '[' , ']' ), '' , $string ));
foreach ( $string as $key => $value )
{
if ( $value != '*' )
{
$string [ $key ] = '[' . trim ( $value ) . ']' ;
}
}
return implode ( '.' , $string );
}
}
?>
Usage:
Identical to http://www.weberdev.com/get_example-4811.html
Specify your connection settings and create a link to a MySQL database. Categories : PHP , PHP Classes , Databases , MySQL , Beginner Guides PHP5 SQLite Abstraction class Categories : PHP , PHP Classes , SQLite , Databases mySQL/PHP/search with multientry
form and table output with colored rows Categories : PHP , Beginner Guides , MySQL , HTML and PHP , Databases Mssql database Manager Categories : PHP , Databases , MS SQL Server , Classes and Objects , PHP Classes A beginner's session handling class Categories : PHP , PHP Classes , Sessions , Beginner Guides Database and Recordset classes fo SyBASE Usage is obvious. Categories : Sybase , Databases , PHP Classes , PHP Recordset Class like ADO Recordset (plus DataBase Splitting feature) using ODBC functions Categories : PHP Classes , ODBC , Databases , PHP Setting up InnoDB on MySQL and using Transactions Begin, Commit, Rollback in PHP. Categories : PHP Classes , Databases , PHP , MySQL , InnoDB PHP Object Example of the Perl DBI with MySQL Categories : PHP , PHP Classes , MySQL , Databases , Perl Link Manager for Link Exchangers Categories : PHP , PHP Classes , Databases , MySQL , CURL A script to generate a report from a valid mysql connection. The user has to supply which fields he wants to display in table. All properties are changable.
Categories : PHP , PHP Classes , Databases , MySQL , HTML and PHP This is a class with functions that are taken from simple SQL statements.
I made it to have an easier connection between PHP3 and DBase files. Categories : General SQL , PHP , PHP Classes , Databases Simple database class Categories : PHP , PHP Classes , MySQL , Databases Ajax PHP Tree (Left and Right) with MySQL Categories : PHP , Databases , MySQL , AJAX , PHP Classes YellowPages Content Grabber (PHP5 +) Categories : PHP , PHP Classes , Regexps , Databases , MySQL