public function getById($id = null)
{
if ($id != null) {
$this->model->setId($id);
}
$data = $this->db->fetchRow("SELECT * FROM targeting_rules WHERE id = ?", $this->model->getId());
if ($data["id"]) {
$data["conditions"] = Serialize::unserialize($data["conditions"]);
$data["actions"] = isset($data["actions"]) ? Serialize::unserialize($data["actions"]) : [];
$this->assignVariablesToModel($data);
} else {
throw new \Exception("target with id " . $this->model->getId() . " doesn't exist");
}
}