public function update(array $data, int $id): void
{
$this->checkFields($data);
$params = [];
$set = "";
foreach($data as $key => $value)
{
$set .= ($set ? "," : "") . "`$key` = ?";
$params[] = $value;
}
$params[] = $id;
$sql = "UPDATE `$this->table` SET $set WHERE `$this->primary`=?";
$this->db->prepare($sql)->execute($params);
}
public function delete($id)
{
$sql = "DELETE FROM `$this->table` WHERE `$this->primary`=?";
$this->db->prepare($sql)->execute([$id]);
}
Ну можно так как у меня показано, или можно так как у вас, через num_rows