0

when I run the method:

public function latest_idf() {
        global $database;
        $sql = "SELECT  FROM ".self::$table_name;
        $result_id=($database->query($sql));
            return ($result_id);

}

the variable $result_id returns resource (11) of type ("mysql result") or Resource id #5 which I need to parse to integer for max id number, how can I return the $result_id as a number integer ?

Resource id #5 it is not my max row.

I have 6 row and in my table.

Did max(id) is beginning from 0 to 5 ?

4

1 回答 1

0

Resource id #5表示您的 query() 方法实际上返回了指向结果的“指针”,而不是结果本身。

根据您在后台使用的库来访问 mysql,您需要从此资源中检索数据。如果您正在使用 mysql_* 函数,例如可以使用:

$row = mysql_fetch_array($resualt_id);
return $row[0];
于 2012-05-21T09:28:11.207 回答