Answer the question
In order to leave comments, you need to log in
How to pass the result of the Model to the View?
Method in controller:
public function createUser()
{
$model = new UserModel();
$result_create = $model->createUser($POST = '');
$view = new afterCreateView();
// если удачно то
$result = $view->succsessUserCreate($result_create);
// если неудачно то
$result = $view->failUserCreate($result_create);
return $result;
}
$res = array(
'error' => 1,
'error_msg' => 'Такой e-mail уже есть в БД'
);
$res['error'] === 0
Answer the question
In order to leave comments, you need to log in
You create the $errors variable in the model and store all the errors in the array there, and the method adds the error there. However, this method only returns true or false. Accordingly, the action will be something like this:
if($model->someMethod()){
return $view->succsessUserCreate($result_create);
}
return $view->failUserCreate($result_create,$model->errors);
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question