【发布时间】:2011-10-12 18:50:24
【问题描述】:
我像这样扩展了 mysqli_result 类:
class mysqli_Extended extends mysqli {
public function Execute($query) {
$this->real_query($query);
return new mysqliResult_Extended($this);
}
public function Insert_Id() {
return $this->insert_id;
}
public function Affected_Rows() {
return $this->affected_rows;
}
}
class mysqliResult_Extended extends MySQLi_Result {
public $fields;
public $queryResults;
public $row_count;
public function __construct($opt) {
parent::__construct($opt);
$this->queryResults = $this->fetch_all(MYSQLI_BOTH); <-- this is line 28
$this->fields = $this->queryResults[0];
$this->row_count = $this->num_rows; <-- this is line 30
$this->close(); <-- this is line 31
}
public function getrows() {
return $this->queryResults;
}
public function recordcount() {
return $this->row_count;
}
}
每次我执行使用 INSERT 的查询时,都会收到以下错误:
Warning: mysqli_result::fetch_all() [mysqli-result.fetch-all]: Couldn't fetch mysqliResult_Extended in /home/xxx/xxx/xxx/xxx/dB.class.php on line 28
Warning: mysqliResult_Extended::__construct() [mysqliresult-extended.--construct]: Couldn't fetch mysqliResult_Extended in /home/xxx/xxx/xxx/xxx/dB.class.php on line 30
Warning: mysqli_result::close() [mysqli-result.close]: Couldn't fetch mysqliResult_Extended in /home/xxx/xxx/xxx/xxx/dB.class.php on line 31
如果我执行 SELECT 类型的查询,则没有错误。
有什么可能导致这种情况的想法吗?
【问题讨论】:
-
我认为
MySQLi_Result不能扩展,必须从mysqli::query()返回。 -
这段代码用于在我家的服务器上工作,但现在我将它迁移到我的在线服务器,它抛出了这个错误。
-
两台服务器的 PHP 和 MySQL 版本是多少?
-
使用mysqlnd编译的在线服务器上的php是5.3.6,mysql是5.0.92
-
试试看配置有没有区别。