summaryrefslogtreecommitdiff
path: root/app/Model
diff options
context:
space:
mode:
Diffstat (limited to 'app/Model')
-rw-r--r--app/Model/Link.php46
-rw-r--r--app/Model/Swimlane.php2
2 files changed, 19 insertions, 29 deletions
diff --git a/app/Model/Link.php b/app/Model/Link.php
index 42b8382c..b26a01e4 100644
--- a/app/Model/Link.php
+++ b/app/Model/Link.php
@@ -112,7 +112,7 @@ class Link extends Base
* @access public
* @param string $label
* @param string $opposite_label
- * @return boolean
+ * @return boolean|integer
*/
public function create($label, $opposite_label = '')
{
@@ -123,38 +123,28 @@ class Link extends Base
return false;
}
+ $label_id = $this->db->getConnection()->getLastId();
+
if ($opposite_label !== '') {
- $this->createOpposite($opposite_label);
+
+ $this->db
+ ->table(self::TABLE)
+ ->insert(array(
+ 'label' => $opposite_label,
+ 'opposite_id' => $label_id,
+ ));
+
+ $this->db
+ ->table(self::TABLE)
+ ->eq('id', $label_id)
+ ->update(array(
+ 'opposite_id' => $this->db->getConnection()->getLastId()
+ ));
}
$this->db->closeTransaction();
- return true;
- }
-
- /**
- * Create the opposite label (executed inside create() method)
- *
- * @access private
- * @param string $label
- */
- private function createOpposite($label)
- {
- $label_id = $this->db->getConnection()->getLastId();
-
- $this->db
- ->table(self::TABLE)
- ->insert(array(
- 'label' => $label,
- 'opposite_id' => $label_id,
- ));
-
- $this->db
- ->table(self::TABLE)
- ->eq('id', $label_id)
- ->update(array(
- 'opposite_id' => $this->db->getConnection()->getLastId()
- ));
+ return $label_id;
}
/**
diff --git a/app/Model/Swimlane.php b/app/Model/Swimlane.php
index cfd6d4a7..3b78a406 100644
--- a/app/Model/Swimlane.php
+++ b/app/Model/Swimlane.php
@@ -87,7 +87,7 @@ class Swimlane extends Base
return $this->db->table(self::TABLE)
->eq('project_id', $project_id)
->eq('name', $name)
- ->findAll();
+ ->findOne();
}
/**