diff options
author | Bruno Skvorc <bruno@skvorc.me> | 2016-02-07 19:13:34 +0100 |
---|---|---|
committer | Bruno Skvorc <bruno@skvorc.me> | 2016-02-07 19:13:34 +0100 |
commit | f6f000105819675cc4f72578bb8311e48f88f4c1 (patch) | |
tree | eeaeaad85ffbc51c5c5cadbea6f4e640655941af /src/Psecio/Gatekeeper/DataSource/Mysql.php | |
parent | 706a1f0540f43d09fd4862cceb55eebd4c122193 (diff) | |
download | gatekeeper-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.php | 13 |
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; |