3.2.3 - 普通 - 未处理
当连接oracle用pdo 执行insert时会报以下错误 ::(
SQLSTATE[IM001]: Driver does not support this function: driver does not support lastInsertId()
错误位置
FILE: /www/test/ThinkPHP/Library/Think/Db/Driver/Oracle.class.php LINE: 87
TRACE
#0 /www/test/ThinkPHP/Library/Think/Db/Driver/Oracle.class.php(87): PDO->lastInsertId()
oracle是不支持lastinsertid()的
以下是网上找到的解决方案:
$this->bind = $this->bind ? $this->bind : $bind; //新增
foreach ($this->bind as $key => $val) {
if(is_array($val)){
$this->PDOStatement->bindValue($key, $val[0], $val[1]);
}else{
$this->PDOStatement->bindValue($key, $val);
}
}
$this->bind = array();
$result = $this->PDOStatement->execute();
$this->debug(false);
if ( false === $result) {
$this->error();
return false;
} else {
$this->numRows = $this->PDOStatement->rowCount();
if($flag || preg_match("/^\s*(INSERT\s+INTO|REPLACE\s+INTO)\s+/i", $str)) {
// $this->lastInsID = $this->_linkID->lastInsertId();
$this->lastInsID = $this->lastInsertId($this->table); //修改
}
return $this->numRows;
} 