Skip to content

Commit

Permalink
fix inserting an already loaded record again (duplicating), bcosca/fa…
Browse files Browse the repository at this point in the history
  • Loading branch information
ikkez committed Nov 25, 2019
1 parent c7b815c commit 5ba562f
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions db/sql/mapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -434,6 +434,15 @@ function insert() {
\Base::instance()->call($this->trigger['beforeinsert'],
[$this,$pkeys])===FALSE)
return $this;
if ($this->valid())
// duplicate record
foreach ($this->fields as $key=>&$field) {
$field['changed']=true;
if ($field['pkey'] && !$inc && $field['pdo_type']==\PDO::PARAM_INT
&& !$field['nullable'])
$inc=$key;
unset($field);
}
foreach ($this->fields as $key=>&$field) {
if ($field['pkey']) {
$field['previous']=$field['value'];
Expand All @@ -451,6 +460,7 @@ function insert() {
$actr++;
$ckeys[]=$key;
}
unset($field);
}
if ($fields) {
$add=$aik='';
Expand Down

0 comments on commit 5ba562f

Please sign in to comment.