I have this sqlite3 db:
CREATE TABLE links (
id INTEGER PRIMARY KEY AUTOINCREMENT,
name TEXT UNIQUE,
link1 TEXT,
link2 TEXT,
link3 TEXT
);
And I am trying to insert multiple entries in the same query, this is my code:
$db = new PDO('sqlite:db.sqlite');
$sql = "INSERT INTO links VALUES";
$filelines = file('filename');
foreach($filelines as $key => $line)
{
if(count($filelines)-1==$key)
$sql .= "(NULL, '".trim($line)."', '', '', '');";
else
$sql .= "(NULL, '".trim($line)."', '', '', ''),";
}
$insert = $db->prepare($sql);
$insert->execute();
Single inserts works fine but with this code I get the php error:
Call to a member function execute() on a non-object
I've also tried creating the sql query like 'VALUES(...,...), VALUES(...,...),... but get the same error:
What am I doing wrong?