升级TP到6.0.7
This commit is contained in:
1 parent
970c71ed14
commit
1bcdd65900
734 files changed
+45008
-5133
No files matched your search
+29
-17
@@ -267,6 +267,7 @@ abstract class Model implements JsonSerializable, ArrayAccess, Arrayable, Jsonab
|
||||
public function newInstance(array $data = [], $where = null): Model
|
||||
{
|
||||
$model = new static($data);
|
||||
$model->readDataType();
|
||||
|
||||
if ($this->connection) {
|
||||
$model->setConnection($this->connection);
|
||||
@@ -455,6 +456,9 @@ abstract class Model implements JsonSerializable, ArrayAccess, Arrayable, Jsonab
|
||||
if ($this->exists) {
|
||||
$this->data = $this->db()->find($this->getKey())->getData();
|
||||
$this->origin = $this->data;
|
||||
$this->get = [];
|
||||
$this->set = [];
|
||||
$this->readDataType();
|
||||
|
||||
if ($relation) {
|
||||
$this->relation = [];
|
||||
@@ -609,10 +613,12 @@ abstract class Model implements JsonSerializable, ArrayAccess, Arrayable, Jsonab
|
||||
return true;
|
||||
}
|
||||
|
||||
if ($this->autoWriteTimestamp && $this->updateTime && !isset($data[$this->updateTime])) {
|
||||
$data = $this->writeDataType($data);
|
||||
|
||||
if ($this->autoWriteTimestamp && $this->updateTime) {
|
||||
// 自动写入更新时间
|
||||
$data[$this->updateTime] = $this->autoWriteTimestamp($this->updateTime);
|
||||
$this->data[$this->updateTime] = $data[$this->updateTime];
|
||||
$data[$this->updateTime] = $this->autoWriteTimestamp();
|
||||
$this->data[$this->updateTime] = $this->getTimestampValue($data[$this->updateTime]);
|
||||
}
|
||||
|
||||
// 检查允许字段
|
||||
@@ -666,34 +672,37 @@ abstract class Model implements JsonSerializable, ArrayAccess, Arrayable, Jsonab
|
||||
*/
|
||||
protected function insertData(string $sequence = null): bool
|
||||
{
|
||||
// 时间戳自动写入
|
||||
if ($this->autoWriteTimestamp) {
|
||||
if ($this->createTime && !isset($this->data[$this->createTime])) {
|
||||
$this->data[$this->createTime] = $this->autoWriteTimestamp($this->createTime);
|
||||
}
|
||||
|
||||
if ($this->updateTime && !isset($this->data[$this->updateTime])) {
|
||||
$this->data[$this->updateTime] = $this->autoWriteTimestamp($this->updateTime);
|
||||
}
|
||||
}
|
||||
|
||||
if (false === $this->trigger('BeforeInsert')) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$this->checkData();
|
||||
$data = $this->writeDataType($this->data);
|
||||
|
||||
// 时间戳自动写入
|
||||
if ($this->autoWriteTimestamp) {
|
||||
if ($this->createTime && !isset($data[$this->createTime])) {
|
||||
$data[$this->createTime] = $this->autoWriteTimestamp();
|
||||
$this->data[$this->createTime] = $this->getTimestampValue($data[$this->createTime]);
|
||||
}
|
||||
|
||||
if ($this->updateTime && !isset($data[$this->updateTime])) {
|
||||
$data[$this->updateTime] = $this->autoWriteTimestamp();
|
||||
$this->data[$this->updateTime] = $this->getTimestampValue($data[$this->updateTime]);
|
||||
}
|
||||
}
|
||||
|
||||
// 检查允许字段
|
||||
$allowFields = $this->checkAllowFields();
|
||||
|
||||
$db = $this->db();
|
||||
|
||||
$db->transaction(function () use ($sequence, $allowFields, $db) {
|
||||
$db->transaction(function () use ($data, $sequence, $allowFields, $db) {
|
||||
$result = $db->strict(false)
|
||||
->field($allowFields)
|
||||
->replace($this->replace)
|
||||
->sequence($sequence)
|
||||
->insert($this->data, true);
|
||||
->insert($data, true);
|
||||
|
||||
// 获取自动增长主键
|
||||
if ($result) {
|
||||
@@ -958,7 +967,10 @@ abstract class Model implements JsonSerializable, ArrayAccess, Arrayable, Jsonab
|
||||
*/
|
||||
public function __unset(string $name): void
|
||||
{
|
||||
unset($this->data[$name], $this->relation[$name]);
|
||||
unset($this->data[$name],
|
||||
$this->get[$name],
|
||||
$this->set[$name],
|
||||
$this->relation[$name]);
|
||||
}
|
||||
|
||||
// ArrayAccess
|
||||
|
||||
Reference in new issue
Block a user