Permalink
Browse files

Merge pull request #418 from majna/2.1-model

Cleanup some Model code and update doc block
  • Loading branch information...
2 parents c718b10 + d2dd861 commit 7e9e3f92a7532d3e5c6db287cd1a2a4d6816ad9d @lorenzo lorenzo committed Jan 17, 2012
Showing with 7 additions and 10 deletions.
  1. +7 −10 lib/Cake/Model/Model.php
@@ -447,6 +447,7 @@ class Model extends Object implements CakeEventListener {
* - `unique`: If true (default value) cake will first delete existing relationship
* records in the foreign keys table before inserting new ones, when updating a
* record. So existing associations need to be passed again when updating.
+ * To prevent deletion of existing relationship records, set this key to a string 'keepExisting'.
* - `conditions`: An SQL fragment used to filter related model records. It's good
* practice to use model names in SQL fragments: "Comment.status = 1" is always
* better than just "status = 1."
@@ -2034,7 +2035,7 @@ public function saveMany($data = null, $options = array()) {
if ($options['atomic']) {
$db = $this->getDataSource();
- $transactionBegun = $db->begin($this);
+ $transactionBegun = $db->begin();
}
$return = array();
foreach ($data as $key => $record) {
@@ -2055,12 +2056,12 @@ public function saveMany($data = null, $options = array()) {
}
if ($validates) {
if ($transactionBegun) {
- return $db->commit($this) !== false;
+ return $db->commit() !== false;
} else {
return true;
}
}
- $db->rollback($this);
+ $db->rollback();
return false;
}
@@ -2138,7 +2139,7 @@ public function saveAssociated($data = null, $options = array()) {
}
if ($options['atomic']) {
$db = $this->getDataSource();
- $transactionBegun = $db->begin($this);
+ $transactionBegun = $db->begin();
}
$associations = $this->getAssociated();
$return = array();
@@ -2200,12 +2201,12 @@ public function saveAssociated($data = null, $options = array()) {
}
if ($validates) {
if ($transactionBegun) {
- return $db->commit($this) !== false;
+ return $db->commit() !== false;
} else {
return true;
}
}
- $db->rollback($this);
+ $db->rollback();
return false;
}
@@ -3234,10 +3235,6 @@ public function getID($list = 0) {
return $this->id;
}
- if (empty($this->id)) {
- return false;
- }
-
if (isset($this->id[$list]) && !empty($this->id[$list])) {
return $this->id[$list];
} elseif (isset($this->id[$list])) {

0 comments on commit 7e9e3f9

Please sign in to comment.