Hi all
I've wirtten some classes that extend some of the mysqli classes, thast basically throw exceptions for the functions that are already there.
Below is the extend mysqli class
class mySQL extends mysqli
{
function prepareStmt($query)
{
$stmt = $this->prepare($query);
if($stmt == false)
{
throw new Exception('MySQL Database Prepare Statment Error: ' .$this->error, $this->errno);
}
return $stmt;
}
}
And here is the extended mysqli_stmt class:
class mySQL_stmt extends mysqli_stmt
{
function executeStmt()
{
if($this->execute() == false)
{
throw new Exception('MySQL Database Execute Error: '.$this->error, $this->errno);
}
}
}
Both are fairly simple in terms of what they do. The problem I am having is when I actually use them together.
// $mySQL has been properly initalised and connected to DB
$stmt = $mySQL->prepareStmt("CALL spGetVotesTotals");
$stmt->executeStmt();
I get the following error:
"Fatal error: Call to undefined method mysqli_stmt::executeStmt()"
Now this makes sense because mySQL->prepareStmt returns a object of mysqli_stmt object and not a mySQL_stmt object.
How do I go about getting this to actually work?
Thanks
Syn