mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-01-19 11:06:15 +00:00
Merge pull request #418 from majna/2.1-model
Cleanup some Model code and update doc block
This commit is contained in:
commit
7e9e3f92a7
1 changed files with 7 additions and 10 deletions
|
@ -447,6 +447,7 @@ class Model extends Object implements CakeEventListener {
|
||||||
* - `unique`: If true (default value) cake will first delete existing relationship
|
* - `unique`: If true (default value) cake will first delete existing relationship
|
||||||
* records in the foreign keys table before inserting new ones, when updating a
|
* records in the foreign keys table before inserting new ones, when updating a
|
||||||
* record. So existing associations need to be passed again when updating.
|
* 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
|
* - `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
|
* practice to use model names in SQL fragments: "Comment.status = 1" is always
|
||||||
* better than just "status = 1."
|
* better than just "status = 1."
|
||||||
|
@ -2034,7 +2035,7 @@ class Model extends Object implements CakeEventListener {
|
||||||
|
|
||||||
if ($options['atomic']) {
|
if ($options['atomic']) {
|
||||||
$db = $this->getDataSource();
|
$db = $this->getDataSource();
|
||||||
$transactionBegun = $db->begin($this);
|
$transactionBegun = $db->begin();
|
||||||
}
|
}
|
||||||
$return = array();
|
$return = array();
|
||||||
foreach ($data as $key => $record) {
|
foreach ($data as $key => $record) {
|
||||||
|
@ -2055,12 +2056,12 @@ class Model extends Object implements CakeEventListener {
|
||||||
}
|
}
|
||||||
if ($validates) {
|
if ($validates) {
|
||||||
if ($transactionBegun) {
|
if ($transactionBegun) {
|
||||||
return $db->commit($this) !== false;
|
return $db->commit() !== false;
|
||||||
} else {
|
} else {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$db->rollback($this);
|
$db->rollback();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2138,7 +2139,7 @@ class Model extends Object implements CakeEventListener {
|
||||||
}
|
}
|
||||||
if ($options['atomic']) {
|
if ($options['atomic']) {
|
||||||
$db = $this->getDataSource();
|
$db = $this->getDataSource();
|
||||||
$transactionBegun = $db->begin($this);
|
$transactionBegun = $db->begin();
|
||||||
}
|
}
|
||||||
$associations = $this->getAssociated();
|
$associations = $this->getAssociated();
|
||||||
$return = array();
|
$return = array();
|
||||||
|
@ -2200,12 +2201,12 @@ class Model extends Object implements CakeEventListener {
|
||||||
}
|
}
|
||||||
if ($validates) {
|
if ($validates) {
|
||||||
if ($transactionBegun) {
|
if ($transactionBegun) {
|
||||||
return $db->commit($this) !== false;
|
return $db->commit() !== false;
|
||||||
} else {
|
} else {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$db->rollback($this);
|
$db->rollback();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3234,10 +3235,6 @@ class Model extends Object implements CakeEventListener {
|
||||||
return $this->id;
|
return $this->id;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (empty($this->id)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (isset($this->id[$list]) && !empty($this->id[$list])) {
|
if (isset($this->id[$list]) && !empty($this->id[$list])) {
|
||||||
return $this->id[$list];
|
return $this->id[$list];
|
||||||
} elseif (isset($this->id[$list])) {
|
} elseif (isset($this->id[$list])) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue