-
-
Save parzibyte/e0964045a4ab29aa81222c90a833bb10 to your computer and use it in GitHub Desktop.
This file contains 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
<?php | |
function deleteEmployee($id) | |
{ | |
$db = getDatabase(); | |
$statement = $db->prepare("DELETE FROM employees WHERE id = ?"); | |
return $statement->execute([$id]); | |
} | |
function updateEmployee($name, $id) | |
{ | |
$db = getDatabase(); | |
$statement = $db->prepare("UPDATE employees SET name = ? WHERE id = ?"); | |
return $statement->execute([$name, $id]); | |
} | |
function getEmployeeById($id) | |
{ | |
$db = getDatabase(); | |
$statement = $db->prepare("SELECT id, name FROM employees WHERE id = ?"); | |
$statement->execute([$id]); | |
return $statement->fetchObject(); | |
} | |
function saveEmployee($name) | |
{ | |
$db = getDatabase(); | |
$statement = $db->prepare("INSERT INTO employees(name) VALUES (?)"); | |
return $statement->execute([$name]); | |
} | |
function getEmployees() | |
{ | |
$db = getDatabase(); | |
$statement = $db->query("SELECT id, name FROM employees"); | |
return $statement->fetchAll(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment