Skip to content

Instantly share code, notes, and snippets.

@nobodyplace
Created May 31, 2011 05:51
Show Gist options
  • Save nobodyplace/1000033 to your computer and use it in GitHub Desktop.
Save nobodyplace/1000033 to your computer and use it in GitHub Desktop.
try {
$pdo->beginTransaction();
foreach($data as $index => $line):
$sth = $pdo->prepare("INSERT INTO sample (id, date) VALUES (:id, :date)");
$sth->execute(array(
':id' => $line['id'],
':date' => $line['date']
));
$sth->closeCursor();
endforeach;
$pdo->commit();
} catch (Exception $e) {
$pdo->rollBack();
vae_dump($e->getMessage());
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment