|
From: Eric F. <wg...@us...> - 2004-08-04 01:53:11
|
Update of /cvsroot/phpliteadmin/phpLiteAdmin/lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25296/lib Added Files: sqlite.php5 Log Message: Initial Commit --- NEW FILE: sqlite.php5 --- <?php /** * @name phpLiteAdmin * @copyright 2004 phpLiteAdmin Team */ /** * $Id: sqlite.php5,v 1.1 2004/08/04 01:53:02 wgeric Exp $ * Provides wrapper for SQLite database access */ class Database { /** * Constructor * * @param string $database Database name * @param integer $perms File permissions * @param string $error Error message */ function __construct( $database, $perms, $error ) { $this->database = $database; $this->perms = $perms; $this->error = $error; $this->connection = sqlite_open( $this->database, $this->perms, $this->error ); if( $this->connection ) { $this->connected = TRUE; } else { $this->connected = FALSE; } } /** * Public variables */ public $database = ''; public $error = ''; public $connected = FALSE; /** * Protected variables */ protected $perms = 0777; protected $connection = FALSE; /** * Public variables */ private $var; /** * Database query * * @param string $query Database query */ function query( $query ) { if( !( $this->connected ) ) { return FALSE; } return sqlite_query( $this->connection, $query ); } /** * Fetch data from database in an array * * @param resource $result Resource handle from query * @param integer $result_type Type of array data returned * @param boolean $decode_binary Whether or not to decode binary data */ function fetch_array( $result, $result_type = SQLITE_ASSOC, $decode_binary = TRUE ) { if( !( $this->connected ) ) { return FALSE; } return sqlite_fetch_array( $result, $result_type, $decode_binary ); } /** * Destructor */ function __destruct() { if( $this->connected ) { sqlite_close( $this->connection ); $this->connected = FALSE; } } } ?> |