query中:
// 调试结束
$this->debug(false);
if ( false === $result ) {
$this->error();
return false;
} else {
return $this->getResult();
}
execute 中:
// 调试结束
$this->debug(false);
if ( false === $result) {
$this->error();
return false;
} else {
$this->numRows = $this->PDOStatement->rowCount();
if(preg_match("/^\s*(INSERT\s+INTO|REPLACE\s+INTO)\s+/i", $str)) {
$this->lastInsID = $this->_linkID->lastInsertId();
}
return $this->numRows;
}
可以看到,两者的最后返回结果是不一样的,query 返回的是一个结果集,而execute 返回的是影响行数 或者 是插入数据的id !~由此可以看出,query 拿来执行 select 更好一些,execute 哪里执行 update | insert | delete 更好些!~~