it got too annoying throwing exceptions line by line using mysqli, so now i'm trying to wrap up all my mysqli functions so that it throws real exceptions base on the Exception class.
Right now, mysqli's stmt bind_param method can't seem to return its error message no matter what i tried. What's going on?
customized stmt class :
class ext_mysqli_stmt extends mysqli_stmt {
public function bind_param($types, $arr){
if(@!parent::bind_param($types, $arr)){
throw new Exception($this->error);
}
}
}
customized mysqli class :
public function prepare($query){
$stmt = new ext_mysqli_stmt($this, $query);
if(!$stmt) throw new Exception(mysqli_connect_error()." $query");
return $stmt;
}
I tried using mysqli_stmt_error($this) on the stmt class, it didn't work either. The message thrown was just an empty string.
Whereas the error messages appear when i capture them from
set_error_handler.
The error i tried was passing unknown data type such as :
//$mysqli is an instance of ext_mysqli
$stmt = $mysqli->prepare($query);
$stmt->bind_param("3i", $para1, $para2, $para3);