avoid unneeded query in delete()

This commit is contained in:
Ceeram 2012-06-19 15:53:39 +02:00
parent 89b2eddf0b
commit cf18e8d38b

View file

@ -2440,13 +2440,14 @@ class Model extends Object implements CakeEventListener {
break;
}
}
$keys = $this->find('first', array(
'fields' => $this->_collectForeignKeys(),
'conditions' => array($this->alias . '.' . $this->primaryKey => $id),
'recursive' => -1,
'callbacks' => false
));
if ($updateCounterCache) {
$keys = $this->find('first', array(
'fields' => $this->_collectForeignKeys(),
'conditions' => array($this->alias . '.' . $this->primaryKey => $id),
'recursive' => -1,
'callbacks' => false
));
}
}
if ($db->delete($this, array($this->alias . '.' . $this->primaryKey => $id))) {