affected_rows总是返回int(0)

时间:2014-03-01 11:05:15

标签: php mysqli

我想知道有多少行被更新,但函数“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;

enter image description here

此查询更新DB中的行,但php函数$this->connect->affected_rows返回零。有什么想法吗?

0 个答案:

没有答案