mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-02-12 06:56:24 +00:00
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:
parent
16bf452787
commit
b5face3516
1 changed files with 5 additions and 7 deletions
|
@ -1126,19 +1126,17 @@ class Model extends Overloadable {
|
||||||
* @return boolean True on success
|
* @return boolean True on success
|
||||||
*/
|
*/
|
||||||
function del($id = null, $cascade = true) {
|
function del($id = null, $cascade = true) {
|
||||||
if ($id) {
|
if (!empty($id)) {
|
||||||
$this->id = $id;
|
$this->id = $id;
|
||||||
}
|
}
|
||||||
|
|
||||||
$id = $this->id;
|
if ($this->exists() && $this->beforeDelete()) {
|
||||||
|
|
||||||
if ($this->beforeDelete()) {
|
|
||||||
$db =& ConnectionManager::getDataSource($this->useDbConfig);
|
$db =& ConnectionManager::getDataSource($this->useDbConfig);
|
||||||
|
|
||||||
if ($this->id && $db->delete($this)) {
|
if ($this->id && $db->delete($this)) {
|
||||||
$this->_deleteMulti($id);
|
$this->_deleteMulti($this->id);
|
||||||
$this->_deleteHasMany($id, $cascade);
|
$this->_deleteHasMany($this->id, $cascade);
|
||||||
$this->_deleteHasOne($id, $cascade);
|
$this->_deleteHasOne($this->id, $cascade);
|
||||||
$this->afterDelete();
|
$this->afterDelete();
|
||||||
$this->_clearCache();
|
$this->_clearCache();
|
||||||
$this->id = false;
|
$this->id = false;
|
||||||
|
|
Loading…
Add table
Reference in a new issue