Dshafik\MySQL::checkValidResult PHP Method

checkValidResult() public static method

public static checkValidResult ( $result, $function )
        public static function checkValidResult($result, $function)
        {
            if (!$result instanceof \mysqli_result) {
                if ($function != "mysql_fetch_object") {
                    trigger_error($function . "() expects parameter 1 to be resource, " . strtolower(gettype($result)) . " given", E_USER_WARNING);
                }
                if ($function == "mysql_fetch_object") {
                    trigger_error($function . "(): supplied argument is not a valid MySQL result resource", E_USER_WARNING);
                }
                return false;
            }
        }

Usage Example

Example #1
0
 function mysql_tablename($result, $row)
 {
     if (\Dshafik\MySQL::checkValidResult($result, __FUNCTION__)) {
         // @codeCoverageIgnoreStart
         return false;
         // @codeCoverageIgnoreEnd
     }
     // Alias as per http://lxr.php.net/xref/PHP_5_6/ext/mysql/php_mysql.c#321
     return mysql_result($result, $row, 'Table');
 }