Skip to content

Instantly share code, notes, and snippets.

@0bp
Created March 14, 2014 14:09
Show Gist options
  • Select an option

  • Save 0bp/9548383 to your computer and use it in GitHub Desktop.

Select an option

Save 0bp/9548383 to your computer and use it in GitHub Desktop.
SQLite3 FU
<?php
$db = new SQLite3('test.sqlite');
$db->exec('CREATE TABLE IF NOT EXISTS test (column1, column2, column3);');
$stmt = $db->prepare('INSERT INTO test (column1, column2, column3) values (:0, :1, :2)');
$data = array(
array('a', 'b', 'c'),
array('a', 'b', 'c'),
array('x')
);
foreach($data as $row)
{
foreach($row as $index => $column)
{
$stmt->bindValue(':'.$index, $column, SQLITE3_TEXT);
}
$stmt->execute();
$stmt->clear();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment