|
楼主 |
发表于 2005-3-2 19:27:48
|
显示全部楼层
SQLITE
[PHP]
<?php
/**
* db_sqlite.php
*
* Sqlite database support
*
*
* @author: nbxmedia <nbxmedia@163.com>
* @version: $Id$
*/
class DB_class
{
var $database = "";
var $link;
//useless thing.....
var $server = "";
var $username = "";
var $password = "";
var $result = false;
//connect to db
function connect()
{
$this->link = sqlite_popen($this->database, 0666, $error);
if(!$this->link)die($error);
}
//query string
function query($string)
{
if($string)
{
$result = @sqlite_query($this->link, $string);
//if(!$result)die(sqlite_error_string(sqlite_last_error($result)));
return $result;
}
else
{
die("query string was empty.");
}
}
//fetch array
function fetch($result)
{
$this->record = @sqlite_fetch_array($result, SQLITE_ASSOC);
//$key = array_keys($this->record);
return $this->record;
}
//number of query rows
function num_rows($result)
{
return @sqlite_num_rows($result);
}
//last id key you insert to db
function insert_id()
{
return @sqlite_last_insert_rowid($this->link);
}
function free($result)
{
unset($result);
return 0;
}
}
?>
[/PHP] |
|