This question already has an answer here:
- PHP SQLite JSON Data Duplication 2 answers
I'm attempting to convert some old sqlite3 database code into sqlite3 prepared statements to improve security on my site. I was considering switching to mysql but as of right now I'd like to get this working first.
I can't see what I've done wrong here, but all of my results are doubled.
Here is my code:
$sql = $upc->prepare("SELECT `uid`, `model`, `biosmodel`, `upc`, `systemsku`, `brand`, `hardwareids`, `status`, `pendingHardware` FROM `builds` WHERE `uid`=:id");
$sql->bindValue(':id', $uid, SQLITE3_INTEGER);
$result = $sql->execute();
echo "<pre>".print_r($result->fetchArray(),true)."</pre>";
My result is an array that has all of my keys, but also duplicated entries that seem to just be regular array keys 0-8
with duplicated information, like so:
Array
(
[0] => 7
[uid] => 7
[1] => HP 15-AY041WM
[model] => HP 15-AY041WM
[2] => HP Notebook
[biosmodel] => HP Notebook
[3] => 889899757697
[upc] => 889899757697
[4] => X0H86UA#ABA
[systemsku] => X0H86UA#ABA
[5] => HP
[brand] => HP
[6] => [42,43,36,44,5,6,45,38,46,41,41,33]
[hardwareids] => [42,43,36,44,5,6,45,38,46,41,41,33]
[7] => 0
[status] => 0
[8] =>
[pendingHardware] =>
)
I'm not really sure why this is happening, and obviously I don't want all this duplicated information as it is needless. How can I resolve this issue?
</div>