Skip to content

Instantly share code, notes, and snippets.

@jankeesvw
Created June 11, 2010 13:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jankeesvw/434456 to your computer and use it in GitHub Desktop.
Save jankeesvw/434456 to your computer and use it in GitHub Desktop.
<?php
class NewsImage extends AppModel {
var $name = 'NewsImage';
var $belongsTo = array(
'News' => array(
'className' => 'News',
'foreignKey' => 'news_id',
'conditions' => '',
'fields' => '',
'order' => ''
)
);
function beforeDelete(){
$this->data = $this->findById($this->id);
return true;
}
function afterDelete() {
$filePath = WWW_ROOT.'img/'.$this->data["NewsImage"]["url"];
unlink($filePath);
return true;
}
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment