mirror of
https://gitee.com/fastadminnet/framework.git
synced 2026-07-07 07:12:47 +08:00
query类增加sequence方法 用于设置 自增序列名
This commit is contained in:
@@ -367,11 +367,12 @@ abstract class Connection
|
|||||||
* @param array $bind 参数绑定
|
* @param array $bind 参数绑定
|
||||||
* @param boolean $fetch 不执行只是获取SQL
|
* @param boolean $fetch 不执行只是获取SQL
|
||||||
* @param boolean $getLastInsID 是否获取自增ID
|
* @param boolean $getLastInsID 是否获取自增ID
|
||||||
|
* @param string $sequence 自增序列名
|
||||||
* @return int
|
* @return int
|
||||||
* @throws DbBindParamException
|
* @throws DbBindParamException
|
||||||
* @throws PDOException
|
* @throws PDOException
|
||||||
*/
|
*/
|
||||||
public function execute($sql, $bind = [], $fetch = false, $getLastInsID = false)
|
public function execute($sql, $bind = [], $fetch = false, $getLastInsID = false, $sequence = null)
|
||||||
{
|
{
|
||||||
$this->initConnect(true);
|
$this->initConnect(true);
|
||||||
if (!$this->linkID) {
|
if (!$this->linkID) {
|
||||||
@@ -403,7 +404,7 @@ abstract class Connection
|
|||||||
|
|
||||||
$this->numRows = $this->PDOStatement->rowCount();
|
$this->numRows = $this->PDOStatement->rowCount();
|
||||||
if (preg_match("/^\s*(INSERT\s+INTO|REPLACE\s+INTO)\s+/i", $sql)) {
|
if (preg_match("/^\s*(INSERT\s+INTO|REPLACE\s+INTO)\s+/i", $sql)) {
|
||||||
$this->lastInsID = $this->linkID->lastInsertId();
|
$this->lastInsID = $this->linkID->lastInsertId($sequence);
|
||||||
if ($getLastInsID) {
|
if ($getLastInsID) {
|
||||||
return $this->lastInsID;
|
return $this->lastInsID;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1059,6 +1059,18 @@ class Query
|
|||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设置自增序列名
|
||||||
|
* @access public
|
||||||
|
* @param string $sequence 自增序列名
|
||||||
|
* @return $this
|
||||||
|
*/
|
||||||
|
public function sequence($sequence = null)
|
||||||
|
{
|
||||||
|
$this->options['sequence'] = $sequence;
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取数据表信息
|
* 获取数据表信息
|
||||||
* @access public
|
* @access public
|
||||||
@@ -1312,7 +1324,7 @@ class Query
|
|||||||
// 生成SQL语句
|
// 生成SQL语句
|
||||||
$sql = $this->builder()->insert($data, $options, $replace);
|
$sql = $this->builder()->insert($data, $options, $replace);
|
||||||
// 执行操作
|
// 执行操作
|
||||||
return $this->execute($sql, $this->getBind(), $options['fetch_sql'], $getLastInsID);
|
return $this->execute($sql, $this->getBind(), $options['fetch_sql'], $getLastInsID, isset($options['sequence']) ? $options['sequence'] : null);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user