MySQLi error handling

Well, one way would be to override the class:

class myMySQLi extends MySQLi {

    public function query($query, $resultmode = MYSQLI_STORE_RESULT) {
        $res = parent::query($query, $resultmode);
        if (!$res) {
            //handle error
        }
        return $res;
    }
}

Then just use as normal, except instead of creating an connection via new MySQLi(), use new myMySQLi(). Other than the error handling, it'll run just the same. I do this quite often, to throw exceptions on errors and to add additional functionality to MySQLi...