使用sqlite的时候出现问题,无法读出数据,支持sqlite3的环境可以正常

class MyDB extends SQLite3
{
    function __construct()
    {
  $db = "/path/to/data.db";
        $this->open($db);
    }
}

$db = new MyDB();
// $db->exec('CREATE TABLE foo (bar STRING)');
// $db->exec("INSERT INTO foo (bar) VALUES ('This is a test')");

$result = $db->query('SELECT * FROM table');
var_dump($result->fetch());


sqlite函数的不行,提示“file is encrypted or is not a database”

if ($db = sqlite_open($db, 0666, $sqliteerror)) {
    // sqlite_query($db, 'CREATE TABLE foo (bar varchar(10))');
    // sqlite_query($db, "INSERT INTO foo VALUES ('fnord')");
    $result = sqlite_query($db, 'select bar from foo');
    var_dump(sqlite_fetch_array($result));
} else {
    die($sqliteerror);
}





If you get an error message:
Warning: sqlite_open() [function.sqlite-open]: file is encrypted or is not a database
then most probably your code is accessing a SQLite3 database.
sqlite_open() only supports SQLite2.  Use PDO to access SQLite3.

sqlite_open()只支持sqlite2版本,暂不支持sqlite3版本;
若连接sqlite3必须用sqlite_pdo去连接,参考下面的代码:
分页: 1/1 第一页 1 最后页 [ 显示模式: 摘要 | 列表 ]

阅读推荐

服务器相关推荐

开发相关推荐

应用软件推荐