git-svn-id: http://xe-core.googlecode.com/svn/trunk@957 201d5d3c-b55e-5fd7-737f-ddc643e51545

This commit is contained in:
zero 2007-04-04 05:28:44 +00:00
parent d0df72c603
commit b2f81c120e

View file

@ -1,20 +1,20 @@
<?php
/**
* @class DBSqlite
* @class DBSqlite3
* @author zero (zero@nzeo.com)
* @brief MySQL DBMS를 이용하기 위한 class
* @version 0.1
*
* sqlite handling class
* sqlite3 handling class
**/
class DBSqlite extends DB {
class DBSqlite3 extends DB {
var $database = NULL; ///< database
var $prefix = 'zb'; ///< 제로보드에서 사용할 테이블들의 prefix (한 DB에서 여러개의 제로보드 설치 가능)
/**
* @brief sqlite 에서 사용될 column type
* @brief sqlite3 에서 사용될 column type
*
* column_type은 schema/query xml에서 공통 선언된 type을 이용하기 때문에
* DBMS에 맞게 replace 해주어야 한다
@ -32,7 +32,7 @@
/**
* @brief constructor
**/
function DBSqlite() {
function DBSqlite3() {
$this->_setDBInfo();
$this->_connect();
}
@ -55,7 +55,7 @@
if(!$this->database) return;
// 데이터 베이스 파일 접속 시도
$this->fd = sqlite_open($this->database, 0666, &$error);
$this->fd = sqlite3_open($this->database, 0666, &$error);
if(!file_exists($this->database) || $error) {
//$this->setError(-1,'permission denied to access database');
$this->setError(-1,$error);
@ -73,7 +73,7 @@
function close() {
if(!$this->isConnected()) return;
sqlite_close($this->fd);
sqlite3_close($this->fd);
}
/**
@ -100,14 +100,14 @@
$this->query = $query;
$this->setError(0,'success');
@sqlite_query("BEGIN;", $this->fd);
$result = @sqlite_query($query, $this->fd);
if(sqlite_last_error($this->fd)) {
@sqlite_query("ROLLBACK;", $this->fd);
$this->setError(sqlite_last_error($this->fd), sqlite_error_string(sqlite_last_error($this->fd)));
@sqlite3_query("BEGIN;", $this->fd);
$result = @sqlite3_query($query, $this->fd);
if(sqlite3_last_error($this->fd)) {
@sqlite3_query("ROLLBACK;", $this->fd);
$this->setError(sqlite3_last_error($this->fd), sqlite3_error_string(sqlite3_last_error($this->fd)));
return;
} else {
@sqlite_query("COMMIT;", $this->fd);
@sqlite3_query("COMMIT;", $this->fd);
}
return $result;
@ -119,7 +119,7 @@
function _fetch($result) {
if($this->errno!=0 || !$result) return;
while($tmp = sqlite_fetch_array($result, SQLITE_ASSOC)) {
while($tmp = sqlite3_fetch_array($result, SQLITE_ASSOC)) {
unset($obj);
foreach($tmp as $key => $val) $obj->{$key} = $val;
$output[] = $obj;
@ -135,7 +135,7 @@
function getNextSequence() {
$query = sprintf("insert into %ssequence (seq) values ('')", $this->prefix);
$this->_query($query);
return sqlite_last_insert_rowid($this->fd);
return sqlite3_last_insert_rowid($this->fd);
}
/**
@ -144,7 +144,7 @@
function isTableExists($target_name) {
$query = sprintf('pragma table_info(%s%s)', $this->prefix, $this->addQuotes($target_name));
$result = $this->_query($query);
if(sqlite_num_rows($result)==0) return false;
if(sqlite3_num_rows($result)==0) return false;
return true;
}