Good day! The problem is this: during the execution of action in the controller, it is not possible to call a method from the model. The call looks like this:
$userId = User::checkUserData($email, $password); The code for the action itself:
public function actionLogin() { $email = ''; $password = ''; if (isset($_POST['submit'])) { $email = $_POST['email']; $password = $_POST['password']; $errors = false; $userId = User::checkUserData($email, $password); if ($userId == false) { $errors[] = "Неверные E-mail или пароль."; } else { User::auth($userId); header("Location: /cabinet/"); } } require_once ROOT.'/views/user/login.php'; return true; } Model Method Code:
public static function checkUserData($email, $password) { $db = Db::getConnection(); $sql = "SELECT * FROM user WHERE email = :email AND password = :password"; $result = $db->prepare($sql); $result->bindParam(':email', $email, PDO::PARAM_STR); $result->bindParam(':password', $password, PDO::PARAM_STR); $result->execute(); $user = $result->fetch(); if ($user) { return $user['id']; } return false; } I found the following error in the logs: PHP Warning: call_user_func_array () expects parameter 1 to be a valid callback
$result = call_user_func_array(array($controllerObject, $actionName), $parameters); All variables are not empty.
This problem is observed when calling any method, but not specifically this. Moreover, the same code is executed normally in Open Server under Windows.
OS - Ubuntu 16.04.1, server - LAMP, PHP version 7.0.
$controllerObject,$actionName? - E_p