1
votes

Hi I'm inserting data using PHP into a SQLite database. I would like to name the fields (i.e., ID, authors etc.) but when the data gets inserted I get extra data where [0] = [ID] and [1] = [authors]

$sql = "INSERT INTO citation (ID,authors, etc.) 
            VALUES ('$ID','$AF', etc.)";
$db->exec($sql);    

gives this when printed:

[0] => 0
[ID] => 0
[1] => Li, Shun-Li;Xu, Qiang
[authors] => Li, Shun-Li;Xu, Qiang

Is this problem inherent in SQLite databases and I should just live with it? Or am I inserting it wrong?

1

1 Answers

1
votes

Please read the documentation on SQLite3Result::fetchArray().

Fetches a result row as an associative or numerically indexed array or both. By default, fetches as both.

So instead of

SQLite3Result::fetchArray()

use

SQLite3Result::fetchArray(SQLITE3_ASSOC)