PHP SQLite JSON Data Duplication

krarinkas

New Member
I have the following PHP code:\[code\]$testMessage = "TESTMESSAGE";$db = new SQLite3('messages.sq3');$db->exec('CREATE TABLE messages(id INTEGER PRIMARY KEY, message CHAR(255));');$db->exec("INSERT INTO messages (message) VALUES ('$testMessage');");$results = $db->query('SELECT * FROM messages ORDER BY id DESC LIMIT 5');while ($row = $results->fetchArray()) { print_r($row);}\[/code\]The resulting print_r:\[code\]Array ( [0] => 1 [id] => 1 [1] => TESTMESSAGE [message] => TESTMESSAGE )\[/code\]Why is this data duplicated? Is this just the way the array is presented or are there really two copies of TESTMESSAGE string? Inspecting the sqlite file, I only see one actually stored there. I am trying to serialize the output via JSON and this duplication is carrying through to the serialization.
 
Back
Top