| 包 | XS.util.db | 
|---|---|
| 继承关系 | class XSDatabaseSQLite3 » XSDatabase | 
| 版本 | 1.0.0 | 
| 源代码 | sdk/php/util/XSDataSource.class.php | 
| 名称 | 描述 | 定义于 | 
|---|---|---|
| close() | 关闭数据库 | XSDatabaseSQLite3 | 
| connect() | 打开数据库 | XSDatabaseSQLite3 | 
| query() | 执行 SQL 语句查询 | XSDatabaseSQLite3 | 
| query1() | 查询数据库首行 | XSDatabase | 
| setUtf8() | 设置数据库字符集为 UTF-8 | XSDatabase | 
| 
public void close() | 
public function close()
{
    if ($this->obj) {
        $this->obj->close();
        $this->obj = null;
    }
}
关闭数据库
| 
public void connect(array $param) | ||
| $param | array | 连接参数, 包含: path | 
public function connect($param)
{
    try {
        $this->obj = new SQLite3($param['path'], SQLITE3_OPEN_READONLY);
    } catch (Exception $e) {
        throw new XSException($e->getMessage());
    }
}
打开数据库
| 
public mixed query(string $sql) | ||
| $sql | string | 要执行的 SQL 语句 | 
| {return} | mixed | |
public function query($sql)
{
    //echo "[DEBUG] SQL: $sql\n";
    $res = $this->obj->query($sql);
    if ($res === false) {
        throw new XSException('SQLITE3 ERROR(#' . $this->obj->lastErrorCode() . '): ' . $this->obj->lastErrorMsg());
    }
    if (!is_object($res)) {
        $ret = $res;
    } else {
        $ret = array();
        while ($tmp = $res->fetchArray(SQLITE3_ASSOC)) {
            $ret[] = $tmp;
        }
        $res->finalize();
    }
    return $ret;
}
执行 SQL 语句查询
| 包 | XS.util.db | 
|---|---|
| 继承关系 | class XSDatabaseSQLite3 » XSDatabase | 
| 版本 | 1.0.0 | 
| 源代码 | sdk/php/util/XSDataSource.class.php | 
| 名称 | 描述 | 定义于 | 
|---|---|---|
| close() | 关闭数据库 | XSDatabaseSQLite3 | 
| connect() | 打开数据库 | XSDatabaseSQLite3 | 
| query() | 执行 SQL 语句查询 | XSDatabaseSQLite3 | 
| query1() | 查询数据库首行 | XSDatabase | 
| setUtf8() | 设置数据库字符集为 UTF-8 | XSDatabase | 
| 
public void close() | 
public function close()
{
    if ($this->obj) {
        $this->obj->close();
        $this->obj = null;
    }
}
关闭数据库
| 
public void connect(array $param) | ||
| $param | array | 连接参数, 包含: path | 
public function connect($param)
{
    try {
        $this->obj = new SQLite3($param['path'], SQLITE3_OPEN_READONLY);
    } catch (Exception $e) {
        throw new XSException($e->getMessage());
    }
}
打开数据库
| 
public mixed query(string $sql) | ||
| $sql | string | 要执行的 SQL 语句 | 
| {return} | mixed | |
public function query($sql)
{
    //echo "[DEBUG] SQL: $sql\n";
    $res = $this->obj->query($sql);
    if ($res === false) {
        throw new XSException('SQLITE3 ERROR(#' . $this->obj->lastErrorCode() . '): ' . $this->obj->lastErrorMsg());
    }
    if (!is_object($res)) {
        $ret = $res;
    } else {
        $ret = array();
        while ($tmp = $res->fetchArray(SQLITE3_ASSOC)) {
            $ret[] = $tmp;
        }
        $res->finalize();
    }
    return $ret;
}
执行 SQL 语句查询
留下一条评论吧!
请到论坛 登录 后刷新本页面!