Мне очень нужна твоя помощь ...
Как я могу поймать исключение в каскаде?
У меня есть функция (A), которая вызывает другую функцию в другом файле (B), которая вызывает другую функцию в другом файле (C).
Как я могу получить в подвохе функции A ошибки функции C?
Является ли это возможным?
Посмотрите мой пример ниже ... Я старался быть максимально понятным ...
// This code is in a file ( file A ) that call a function of a file B
require_once('/User_Login.php');
try
{
CREATE_NEW_User_Login(arr_Test, 'hello');
return true;
}
catch(Exception $e)
{
echo $e->getMessage();
return false;
}
}
// This code is in another file ( file B ) that call a function of a file C
public function CREATE_NEW_User_Login($_INPUT_Array = null, $_INPUT__Password = null)
{
// Db connection...
require_once('/User__DBclass.php');
$DBCl_User = new User($DBConn, null);
$DBCl_User->SET__CLASS_ATTRIBUTES_Value__by_Array($_INPUT_Array);
$DBCl_User->SETTER__user_pass(md5($_INPUT__Password));
$this->config['mysqli']->beginTransaction();
try
{
$DBCl_User->INSERT__NEW_ROW())
return true;
}
catch(Exception $e)
{
echo $e->getMessage();
return false;
}
}
// This code is in another file ( file C )
// In the User Class ( file: User__DBclass.php )
public function INSERT__NEW_ROW()
{
$this->config['stmt'] = $this->config['mysqli']->prepare('INSERT INTO tbl_user
SET user_id = :user_id,
user_name = :user_name,
act_code = :act_code;');
$this->config['stmt']->bindParam(':user_id', $this->user_id, PDO::PARAM_INT);
$this->config['stmt']->bindParam(':user_name', $this->user_name, PDO::PARAM_STR);
$this->config['stmt']->bindParam(':act_code', $this->act_code, PDO::PARAM_STR);
try
{
$this->config['stmt']->execute();
$this->user_id = intval($this->config['mysqli']->lastInsertId());
return $this->user_id;
}
catch(PDOException $e)
{
echo $e->getMessage();
return false;
}
}