内核更新
This commit is contained in:
@@ -37,8 +37,6 @@ abstract class Connection
|
||||
|
||||
/** @var string 当前SQL指令 */
|
||||
protected $queryStr = '';
|
||||
// 最后插入ID
|
||||
protected $lastInsID;
|
||||
// 返回或者影响记录数
|
||||
protected $numRows = 0;
|
||||
// 事务指令数
|
||||
@@ -699,10 +697,7 @@ abstract class Connection
|
||||
*/
|
||||
public function getLastInsID($sequence = null)
|
||||
{
|
||||
if (is_null($this->lastInsID)) {
|
||||
$this->lastInsID = $this->linkID->lastInsertId($sequence);
|
||||
}
|
||||
return $this->lastInsID;
|
||||
return $this->linkID->lastInsertId($sequence);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1768,12 +1768,18 @@ class Query
|
||||
public function update(array $data)
|
||||
{
|
||||
$options = $this->parseExpress();
|
||||
$pk = $this->getPk($options);
|
||||
if (isset($options['cache']) && is_string($options['cache'])) {
|
||||
$key = $options['cache'];
|
||||
}
|
||||
|
||||
if (empty($options['where'])) {
|
||||
$pk = $this->getPk($options);
|
||||
// 如果存在主键数据 则自动作为更新条件
|
||||
if (is_string($pk) && isset($data[$pk])) {
|
||||
$where[$pk] = $data[$pk];
|
||||
$key = 'think:' . $options['table'] . '|' . $data[$pk];
|
||||
if (!isset($key)) {
|
||||
$key = 'think:' . $options['table'] . '|' . $data[$pk];
|
||||
}
|
||||
unset($data[$pk]);
|
||||
} elseif (is_array($pk)) {
|
||||
// 增加复合主键支持
|
||||
@@ -1793,6 +1799,8 @@ class Query
|
||||
} else {
|
||||
$options['where']['AND'] = $where;
|
||||
}
|
||||
} elseif (is_string($pk) && isset($options['where']['AND'][$pk]) && is_scalar($options['where']['AND'][$pk])) {
|
||||
$key = 'think:' . $options['table'] . '|' . $options['where']['AND'][$pk];
|
||||
}
|
||||
// 生成UPDATE SQL语句
|
||||
$sql = $this->builder()->update($data, $options);
|
||||
@@ -2037,7 +2045,7 @@ class Query
|
||||
public function chunk($count, $callback, $column = null)
|
||||
{
|
||||
$options = $this->getOptions();
|
||||
$column = $column ?: $this->getPk();
|
||||
$column = $column ?: $this->getPk(isset($options['table']) ? $options['table'] : '');
|
||||
$bind = $this->bind;
|
||||
$resultSet = $this->limit($count)->order($column, 'asc')->select();
|
||||
|
||||
@@ -2093,9 +2101,12 @@ class Query
|
||||
{
|
||||
// 分析查询表达式
|
||||
$options = $this->parseExpress();
|
||||
if (isset($options['cache']) && is_string($options['cache'])) {
|
||||
$key = $options['cache'];
|
||||
}
|
||||
|
||||
if (!is_null($data) && true !== $data) {
|
||||
if (!is_array($data)) {
|
||||
if (!isset($key) && !is_array($data)) {
|
||||
// 缓存标识
|
||||
$key = 'think:' . $options['table'] . '|' . $data;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user