我想知道有多少行被更新,但函数“affected_rows”总是返回0.这是我的代码:
$this->connect = new mysqli("mysql.xxx.com","root","mypass","site") or die("error on connect");
$update = $this->connect->query($query);
if($update === true){
$this->html .= '<table class="select-result"><tr><td>Affected rows: '.$this->connect->affected_rows.'</td></tr></table>';
}
var_dump($this->connect->affected_rows); //Returns int(0)
这是我的疑问:
update customers set comment='a' where id=1;
此查询更新DB中的行,但php函数$this->connect->affected_rows
返回零。有什么想法吗?