Why does mysql_query() return TRUE with a SELECT statement?

后端 未结 7 1794
日久生厌
日久生厌 2020-12-20 15:24

According to the manual of mysql_query() and to everything I know about this function that I used so many times, it can either return a resource or FALSE if the

7条回答
  •  别那么骄傲
    2020-12-20 15:57

    mysql_query doesn't return FALSE, let alone TRUE. It returns a resource id that if equates to zero, con be taken as FALSE. My example is to illustrate boolean results

    $resource = mysql_query($query, $handle);
    if (!$resource) throw some exception;
    if (!$resource && strpos($query, 'SELECT')) {
    throw new Exception('mysql_query() returned TRUE for SELECT');
    }
    

    PHP Booleans

提交回复
热议问题