public function getByName($name = null)
{
if ($name != null) {
$this->model->setName($name);
}
$name = $this->model->getName();
$groupId = $this->model->getGroup();
$stmt = "SELECT * FROM " . self::TABLE_NAME_KEYS . " WHERE name = '" . $name . "'";
if ($groupId > 0) {
$stmt .= " AND `group` = " . $groupId;
}
$data = $this->db->fetchRow($stmt);
if ($data["id"]) {
$this->assignVariablesToModel($data);
} else {
throw new \Exception("KeyConfig with name: " . $this->model->getName() . " does not exist");
}
}