我有一个PHP的SQLite查询:sqlite3的同时返回索引和关联数组
$database = new SQLite3("database.db");
$statement = $database->prepare("SELECT * FROM table");
$result = $statement->execute();
$table = array();
while ($row = $result->fetchArray()) {
array_push($table, $row);
}
var_dump($table);
它输出
array(2) {
[0]=> array(4) {
[0]=> int(1)
["event"]=> int(1)
[1]=> string(2) "A1"
["code"]=> string(2) "A1"
}
[1]=> array(4) {
[0]=> int(5)
["event"]=> int(5)
[1]=> string(2) "A2"
["code"]=> string(2) "A2"
}
}
哪一个是正确的数据,但它输出的所有信息两次:一个带有索引,另一个带有列名。有什么办法可以选择其中之一吗?这个程序需要非常有效的内存,因为它将被扩展到有成千上万行。