目前我正在使用:
$result = new SQLite3(sprintf("users/USERIDS_DB.sqlite"));
$numRows = $result->exec ("SELECT count(*) FROM USERIDS");
echo sprintf("the number of rows are: %d", $numRows);
但结果是1,它应该是6(我用firefox sqlite3插件创建的行数)
有人可以帮忙吗?
解决方法:
public bool SQLite3::exec ( string $query )
Executes a result-less query against a given database.
此方法返回布尔值,而不是结果集.当您将true转换为整数时,它将变为1.
你应该使用SQLite3::query().例子(未经测试):
$rows = $result->query("SELECT COUNT(*) as count FROM USERIDS");
$row = $rows->fetchArray();
$numRows = $row['count'];
顺便说一句,命名SQLite3类$结果的实例可能会产生误导(特别是在数据库环境中).我会称之为$db或$connection.
【说明】:本文章由站长整理发布,文章内容不代表本站观点,如文中有侵权行为,请与本站客服联系(QQ:254677821)!