我像这样扩展了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类型的查询,则没有错误。
任何可能导致此问题的想法?
答案 0 :(得分:1)
“我收到以下错误:”
这些不是错误 - 它们是警告。
尝试var_dump($this->queryResults);
,看看你得到了什么。
我的猜测是,在一台服务器上警告被抑制,而另一台服务器则没有警告。
如果要取消警告,可以在函数调用前使用“@”字符,或者按照this question中所示适当设置错误级别。