Created
February 18, 2015 15:40
-
-
Save rsmarshall/3d6696658866fac516ca to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** | |
| * Add an item submitted via the app upload | |
| * | |
| * @param array $items An array of items for adding to the Trolley | |
| * @return void | |
| */ | |
| public function addFromApp($items) | |
| { | |
| $pdo = DB::getPdo(); | |
| $pdo->beginTransaction(); | |
| $statement = $pdo->prepare("INSERT INTO trolley_items ( `trolley_id`,`pack_id`,`price`,`quantity` ) | |
| VALUES | |
| ( ?, ?, ?, ? ) | |
| ON DUPLICATE KEY UPDATE `quantity` = `quantity` + 1"); | |
| foreach ($items as $item) { | |
| $statement->execute(array($item->trolleyId, $item->packId, $item->price, $item->quantity)); | |
| } | |
| $pdo->commit(); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment