In many controllers, I need to verify if an object (ID passed in URL) exists.
I actually have this skeleton for each controller :
public function my_page($id){
$object = $this->Object_model->getObject($id);
if($object == NULL){ // If id mentions a non-existant object, redirect to home
redirect("home");
}
/** MYCONTROLLER **/
}
Is it the good way, the cleanest way to do that ?
Some other options are helpers / model methods / controller methods... I don't know what is the PHP philosophy for that.