I'm trying to
get my head around MySQli and I'm confused by the error reporting.
I am using
the return value of the MySQLi 'prepare' statement to detect errors when executing SQL,
like this:
$stmt_test =
$mysqliDatabaseConnection->stmt_init();
if($stmt_test->prepare("INSERT
INTO testtable VALUES (23,44,56)"))
{
$stmt_test->execute();
$stmt_test->close();
}
else
echo("Statement failed: ". $stmt_test->error . "
/>");
But, is the
return value of the prepare statement only detecting if there is an error in the
preperation of the SQL statement and not detecting execution errors? If so should I
therefore change my execute line to flag errors as well like
this:
if($stmt_test->execute())
$errorflag=true;
And
then just to be safe should I also do the following after the statement has
executed:
if($stmt_test->errno)
{$errorflag=true;}
...Or
was I OK to start with and the return value on the MySQLi prepare' statement captures
all errors associated with the complete execution of the query it
defines?
Thanks
C
No comments:
Post a Comment