Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Nekretnina extends CActiveRecord
- {
- .......
- public function relations()
- {
- return array(
- .....
- 'slike' => array(self::HAS_MANY, 'Slika', 'id_nekretnine'),
- );
- }
- protected function beforeDelete()
- {
- Slika::model()->deleteAll('id_nekretnine='.$this->id);
- return parent::beforeDelete();
- }
- }
- class Slika extends CActiveRecord
- {
- ........
- protected function beforeDelete(){
- unlink(Yii::app()->basePath.'/../images/'.$this->putanja);
- unlink(Yii::app()->basePath.'/../images/.tmb/tmb_'.$this->putanja);
- return parent::beforeDelete();
- }
- }
- "Nekretnina" means real estate, and "Slika" means picture in Serbian.
- When I call delete method from NekretninaController: It deletes all picture(slika) rows that are asociated with that real estate(nekretnina) and then deletes real estate(nekretnina).
- Real estate's(Nekretnina) beforeDelete is called, but picture's(slika) beforeDelete isn't!
- When I call delete action from SlikaController, beforeDelete is called.
- How to activate beforeDelete of Slika model from NekretninaController ?
- Thank you
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement