Changing Model::del to check for existence of itself before allowing deletes

git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@4099 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
nate 2006-12-13 04:04:15 +00:00
parent 16bf452787
commit b5face3516

View file

@ -1126,19 +1126,17 @@ class Model extends Overloadable {
* @return boolean True on success
*/
function del($id = null, $cascade = true) {
if ($id) {
if (!empty($id)) {
$this->id = $id;
}
$id = $this->id;
if ($this->beforeDelete()) {
if ($this->exists() && $this->beforeDelete()) {
$db =& ConnectionManager::getDataSource($this->useDbConfig);
if ($this->id && $db->delete($this)) {
$this->_deleteMulti($id);
$this->_deleteHasMany($id, $cascade);
$this->_deleteHasOne($id, $cascade);
$this->_deleteMulti($this->id);
$this->_deleteHasMany($this->id, $cascade);
$this->_deleteHasOne($this->id, $cascade);
$this->afterDelete();
$this->_clearCache();
$this->id = false;