Created
February 18, 2015 15:16
-
-
Save rsmarshall/56d275ffbca8700e90ce 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 | |
| */ | |
| 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(); | |
| /* | |
| DB::statement("INSERT INTO trolley_items ( `trolley_id`,`pack_id`,`price`,`quantity` ) | |
| VALUES | |
| ( ?, ?, ?, ? ) | |
| ON DUPLICATE KEY UPDATE `quantity` = `quantity` + 1", array($trolleyId, $packId, $price, $quantity)); | |
| */ | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment