Skip to content

Commit 4e27405

Browse files
committed
As discussed in #200
1 parent ee34a99 commit 4e27405

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

api.php

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1134,8 +1134,10 @@ protected function parseGetParameterArray($get,$name,$characters) {
11341134
return $values;
11351135
}
11361136

1137-
protected function applyAfterWrite($callback,$action,$database,$table,$id,$input) {
1137+
protected function applyAfterWrite($action,$table,$id,$input) {
1138+
$callback = $this->settings['after_write'];
11381139
if (is_callable($callback,true)) {
1140+
$database = $this->settings['database'];
11391141
$callback($action,$database,$table,$id,$input);
11401142
}
11411143
}
@@ -1474,8 +1476,7 @@ protected function createObject($input,$tables) {
14741476
$result = $this->db->query('INSERT INTO ! ('.$keys.') VALUES ('.$values.')',$params);
14751477
if (!$result) return null;
14761478
$insertId = $this->db->insertId($result);
1477-
extract($this->settings);
1478-
$this->applyAfterWrite($after_write,'create',$database,$tables[0],$insertId,$input);
1479+
$this->applyAfterWrite('create',$tables[0],$insertId,$input);
14791480
return $insertId;
14801481
}
14811482

@@ -1512,7 +1513,7 @@ protected function updateObject($key,$input,$filters,$tables) {
15121513
$this->addWhereFromFilters($filters[$table],$sql,$params);
15131514
$result = $this->db->query($sql,$params);
15141515
if (!$result) return null;
1515-
$this->applyAfterWrite($after_write,'update',$database,$tables[0],$key[0],$input);
1516+
$this->applyAfterWrite('update',$tables[0],$key[0],$input);
15161517
return $this->db->affectedRows($result);
15171518
}
15181519

@@ -1545,7 +1546,7 @@ protected function deleteObject($key,$filters,$tables) {
15451546
$this->addWhereFromFilters($filters[$table],$sql,$params);
15461547
$result = $this->db->query($sql,$params);
15471548
if (!$result) return null;
1548-
$this->applyAfterWrite($after_write,'delete',$database,$tables[0],$key[0],array());
1549+
$this->applyAfterWrite('delete',$tables[0],$key[0],array());
15491550
return $this->db->affectedRows($result);
15501551
}
15511552

@@ -1590,7 +1591,7 @@ protected function incrementObject($key,$input,$filters,$tables,$fields) {
15901591
$this->addWhereFromFilters($filters[$table],$sql,$params);
15911592
$result = $this->db->query($sql,$params);
15921593
if (!$result) return null;
1593-
$this->applyAfterWrite($after_write,'increment',$database,$tables[0],$key[0],$input);
1594+
$this->applyAfterWrite('increment',$tables[0],$key[0],$input);
15941595
return $this->db->affectedRows($result);
15951596
}
15961597

0 commit comments

Comments
 (0)