1

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 Answer 1

1

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)
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.