mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-01-31 09:06:17 +00:00
Fix for Ticket #1689.
git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@3940 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
parent
553190bb98
commit
2e0ec28018
1 changed files with 9 additions and 9 deletions
|
@ -1159,17 +1159,17 @@ class Model extends Overloadable {
|
|||
* @access protected
|
||||
*/
|
||||
function _deleteHasMany($id, $cascade) {
|
||||
$records = array();
|
||||
|
||||
foreach($this->hasMany as $assoc => $data) {
|
||||
if ($data['dependent'] === true && $cascade === true) {
|
||||
$model =& $this->{$data['className']};
|
||||
$field = $model->escapeField($data['foreignKey']);
|
||||
$model->recursive = 0;
|
||||
$records = $model->findAll("$field = '$id'", $model->primaryKey, null, null);
|
||||
$records = $model->findAll("$field = '$id'", $model->primaryKey, null, null);
|
||||
|
||||
foreach($records as $record) {
|
||||
$model->del($record[$data['className']][$model->primaryKey]);
|
||||
if($records != false){
|
||||
foreach($records as $record) {
|
||||
$model->del($record[$data['className']][$model->primaryKey]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1182,8 +1182,6 @@ class Model extends Overloadable {
|
|||
* @access protected
|
||||
*/
|
||||
function _deleteHasOne($id, $cascade) {
|
||||
$records = array();
|
||||
|
||||
foreach($this->hasOne as $assoc => $data) {
|
||||
if ($data['dependent'] === true && $cascade === true) {
|
||||
$model =& $this->{$data['className']};
|
||||
|
@ -1191,8 +1189,10 @@ class Model extends Overloadable {
|
|||
$model->recursive = 0;
|
||||
$records = $model->findAll("$field = '$id'", $model->primaryKey, null, null);
|
||||
|
||||
foreach($records as $record) {
|
||||
$model->del($record[$data['className']][$model->primaryKey]);
|
||||
if($records != false){
|
||||
foreach($records as $record) {
|
||||
$model->del($record[$data['className']][$model->primaryKey]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue