Kod
class Menu extends ObjectModel {
protected $id_menu;
protected $nazwa_menu;
public function __construct($id=null) {
parent::__construct();
if(!empty($id))
{
if(!is_numeric($id))
return false;
$sql = "SELECT * FROM menu WHERE id_menu = '$id'";
$menu = $this->dbhandle->select($sql);
if(!empty($menu))
$this->setAll($menu[0]);
else
return false;
}
}
}
protected $id_menu;
protected $nazwa_menu;
public function __construct($id=null) {
parent::__construct();
if(!empty($id))
{
if(!is_numeric($id))
return false;
$sql = "SELECT * FROM menu WHERE id_menu = '$id'";
$menu = $this->dbhandle->select($sql);
if(!empty($menu))
$this->setAll($menu[0]);
else
return false;
}
}
}
To jest tylko kod contruktora ale powinno wystarczyć. Co mam zrobić aby w przypadku podania nieprawidłowego id obiekt nie został utworzony?