class UserModel { private $db; public function __construct($db) { $this->db = $db; } public function getUserById($id) { $stmt = $this->db->prepare("SELECT * FROM users WHERE id = ?"); $stmt->bind_param("i", $id); $stmt->execute(); $result = $stmt->get_result(); return $result->fetch_assoc(); } public function updateUser($id, $name, $email) { $stmt = $this->db->prepare("UPDATE users SET name = ?, email = ? WHERE id = ?"); $stmt->bind_param("ssi", $name, $email, $id); $stmt->execute(); } public function deleteUser($id) { $stmt = $this->db->prepare("DELETE FROM users WHERE id = ?"); $stmt->bind_param("i", $id); $stmt->execute(); } }This example uses SQL statements to interact with the database, but there are also package libraries such as Laravel's Eloquent ORM and Yii's Active Record that provide more advanced features such as object-relational mapping and query building.