vendredi 3 avril 2015

SQLite3 returns both indexed and associative array

I have a SQLite query in PHP:



$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);


and it outputs



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"
}
}


Which is the correct data, but it's outputting all of the information twice: one with an index attached, and one with the column name. Is there any way to pick one or the other? This program needs to be very memory efficient as it will be expanded to having thousands of rows.


Aucun commentaire:

Enregistrer un commentaire