Browse Source

src: Add helper function to add new items to inventory

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

12
src/Etu/Helpers/Inventory.php

@ -27,6 +27,18 @@ class Inventory
return ($row = $stmt->fetch()) ? $row : null;
}
public function addItem(string $name, int $stock) : bool
{
// Prepare query
$stmt = $this->db->prepare('INSERT INTO inventory (item_name, item_stock) VALUES (:name, :stock)');
// Bind values
$stmt->bindValue('name', $name, PDO::PARAM_STR);
$stmt->bindValue('stock', $stock, PDO::PARAM_INT);
return $stmt->execute();
}
public function setAmount(string $name, int $newStock) : bool
{
// Prepare query

Loading…
Cancel
Save