Browse Source

src: Add helper function to set new stock amount

master
Elis Hirwing 3 years ago
parent
commit
c9f9aef8a0
Signed by: etu GPG Key ID: D57EFA625C9A925F
  1. 13
      src/Etu/Helpers/Inventory.php

13
src/Etu/Helpers/Inventory.php

@ -26,4 +26,17 @@ class Inventory
return ($row = $stmt->fetch()) ? $row : null;
}
public function setAmount(string $name, int $newStock) : bool
{
// Prepare query
$stmt = $this->db->prepare('UPDATE inventory SET item_stock = :stock WHERE item_name = :item_name');
// Bind values
$stmt->bindValue('item_name', $name, PDO::PARAM_STR);
$stmt->bindValue('stock', $newStock, PDO::PARAM_INT);
// Execute and return result
return $stmt->execute();
}
}

Loading…
Cancel
Save