修正Oracel驱动的execute方法

This commit is contained in:
thinkphp
2016-06-30 21:43:49 +08:00
parent 01340ed33b
commit 37fa2bceca

View File

@@ -47,7 +47,7 @@ class Oracle extends Connection
* @param string $sql sql指令 * @param string $sql sql指令
* @param array $bind 参数绑定 * @param array $bind 参数绑定
* @param boolean $getLastInsID 是否获取自增ID * @param boolean $getLastInsID 是否获取自增ID
* @param string $sequence 序列名 * @param string $sequence 序列名
* @return integer * @return integer
* @throws \Exception * @throws \Exception
* @throws \think\Exception * @throws \think\Exception
@@ -60,16 +60,16 @@ class Oracle extends Connection
} }
// 根据参数绑定组装最终的SQL语句 // 根据参数绑定组装最终的SQL语句
$this->queryStr = $this->getBindSql($sql, $bind); $this->queryStr = $this->getRealSql($sql, $bind);
$flag = false; $flag = false;
if (preg_match("/^\s*(INSERT\s+INTO)\s+(\w+)\s+/i", $sql, $match)) { if (preg_match("/^\s*(INSERT\s+INTO)\s+(\w+)\s+/i", $sql, $match)) {
if(is_null($sequence)){ if (is_null($sequence)) {
$sequence = Config::get("db_sequence_prefix") . str_ireplace(Config::get("database.prefix"), "", $match[2]); $sequence = Config::get("db_sequence_prefix") . str_ireplace(Config::get("database.prefix"), "", $match[2]);
} }
$flag = (boolean) $this->query("SELECT * FROM all_sequences WHERE sequence_name='" . strtoupper($sequence) . "'"); $flag = (boolean) $this->query("SELECT * FROM all_sequences WHERE sequence_name='" . strtoupper($sequence) . "'");
} }
//释放前次的查询结果 //释放前次的查询结果
if (!empty($this->PDOStatement)) { if (!empty($this->PDOStatement)) {
$this->free(); $this->free();
@@ -89,7 +89,7 @@ class Oracle extends Connection
$this->lastInsID = $this->linkID->lastInsertId(); $this->lastInsID = $this->linkID->lastInsertId();
if ($getLastInsID) { if ($getLastInsID) {
return $this->lastInsID; return $this->lastInsID;
} }
} }
return $this->numRows; return $this->numRows;
} catch (\PDOException $e) { } catch (\PDOException $e) {
@@ -130,7 +130,7 @@ class Oracle extends Connection
/** /**
* 取得数据库的表信息(暂时实现取得用户表信息) * 取得数据库的表信息(暂时实现取得用户表信息)
* @access public * @access public
* @param string $dbName * @param string $dbName
* @return array * @return array
*/ */
public function getTables($dbName = '') public function getTables($dbName = '')
@@ -155,7 +155,8 @@ class Oracle extends Connection
return []; return [];
} }
protected function supportSavepoint(){ protected function supportSavepoint()
{
return true; return true;
} }
} }