i’ve wrote a little database class which goes like this:
class dbClass extends mysqli
{
public function execute($sq)
{
$res = parent::query($sq);
$rs = $res->fetch_array();
return $rs;
}
}
works so far, but the poblem is when running a delete query (“delete from mytable where..”)
the class throws an error on that line: $rs = $res->fetch_array(); (as it doesn’t return anything i guess)
the question is: how can i trap this error? it should simple not do fetch_array() on queries like insert, delete, update ..
thanks!
you must check the type of result if it is boolean type do not fetch.
And the other solution could be send addition parameter which holds type of query and check that type before fetching.