Skip to content

Instantly share code, notes, and snippets.

@rsmarshall
Last active August 29, 2015 14:15
Show Gist options
  • Select an option

  • Save rsmarshall/bdadc245fa232a4c7292 to your computer and use it in GitHub Desktop.

Select an option

Save rsmarshall/bdadc245fa232a4c7292 to your computer and use it in GitHub Desktop.
$pdo = new \PDO('mysql:dbname=parfetts;host=localhost', '', '');
$pdo->beginTransaction();
$statement = $pdo->prepare("INSERT INTO trolley_items ( `trolley_id`,`pack_id`,`price`,`quantity` )
VALUES
( ?, ?, ?, ? )
ON DUPLICATE KEY UPDATE `quantity` = `quantity` + 1");
$statement->execute(array($trolleyId, $packId, $price, $quantity));
$pdo->commit();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment