class User{
public $id;
public $name;
public function setId($id){
$this->id = $id;
}
public function setName($name){
$this->name = $name;
}
}
class UserRepository
{
public $db;
public $user;
public function __construct(PDO $db){
$this->db = $db;
}
public function save(User $user){
if(empty($this->user->id)){
$this->db->prepare("INSERT INTO `users` (`name`) VALUE (?)");
$this->db->execute($this->user->name);
}else{
$this->db->prepare("UPDATE `users` SET `name` = ? WHERE `id` = ?");
$this->db->execute($this->user->name, $this->user->id);
}
}
public function delete(int $id){
//del
}
}
class User
{
public $name;
public $age;
public $email;
public function __construct(string $name, string $age, string $email){
$this->name = $name;
$this->age = $age;
$this->email = $email;
}
}
class User
{
public $db;
public function __construct(PDO $db){
$this->db = $db;
}
public function create(array $data){
//INSERT INTO users
}
public function update(array $data){
}
public function delete(int $id){
}
}