summaryrefslogtreecommitdiffstats
path: root/src/Psecio/Gatekeeper/DataSource/Mysql.php
diff options
context:
space:
mode:
authorBruno Skvorc <bruno@skvorc.me>2016-02-07 19:13:34 +0100
committerBruno Skvorc <bruno@skvorc.me>2016-02-07 19:13:34 +0100
commitf6f000105819675cc4f72578bb8311e48f88f4c1 (patch)
treeeeaeaad85ffbc51c5c5cadbea6f4e640655941af /src/Psecio/Gatekeeper/DataSource/Mysql.php
parent706a1f0540f43d09fd4862cceb55eebd4c122193 (diff)
downloadgatekeeper-f6f000105819675cc4f72578bb8311e48f88f4c1.zip
gatekeeper-f6f000105819675cc4f72578bb8311e48f88f4c1.tar.gz
gatekeeper-f6f000105819675cc4f72578bb8311e48f88f4c1.tar.bz2
When the creation of the original record fails, an attempt to create the relations is still made - this, naturally, fails. By moving this block inside the check, the situation is prevented - at least the relations aren't attempted if the original fails.
Diffstat (limited to 'src/Psecio/Gatekeeper/DataSource/Mysql.php')
-rw-r--r--src/Psecio/Gatekeeper/DataSource/Mysql.php13
1 files changed, 6 insertions, 7 deletions
diff --git a/src/Psecio/Gatekeeper/DataSource/Mysql.php b/src/Psecio/Gatekeeper/DataSource/Mysql.php
index 82a28b5..07ec6d8 100644
--- a/src/Psecio/Gatekeeper/DataSource/Mysql.php
+++ b/src/Psecio/Gatekeeper/DataSource/Mysql.php
@@ -117,13 +117,12 @@ class Mysql extends \Psecio\Gatekeeper\DataSource
$result = $this->execute($sql, $data);
if ($result !== false) {
$model->id = $this->getDb()->lastInsertId();
- }
-
- // Now handle the relations - for each of them, get the model, make it and save it
- foreach ($relations as $index => $item) {
- $relation = $properties[$index];
- $instance = new $relation['relation']['model']($this);
- $instance->create($model, $item);
+ // Now handle the relations - for each of them, get the model, make it and save it
+ foreach ($relations as $index => $item) {
+ $relation = $properties[$index];
+ $instance = new $relation['relation']['model']($this);
+ $instance->create($model, $item);
+ }
}
return $result;