hi all,
the title of the post is a bit cryptic I guess …
here is what I am trying to do and what happens :
I am trying to set a custom model property in afterFind method based on data in a related model :
model 1 : Event
model 2 : Artist
I am calling a lazy find in afterFind to get the data I need.
in Event :
public function afterFind() { //add artist ids from related artists objects $this->artistsIds = array();//CUSTOM MODEL PROPERTY foreach($this->Artist as $artist) {//lazy loading of Artists array_push($this->_artistsIds, $artist->id); } parent::afterFind(); }
so far so good, this works
my problem is that I want to do a similar thing in Artist with Event data :
public function afterFind() { if(!empty($this->Event)) { $this->eventName = $this->Event[0]->name; } parent::afterFind(); }
from here I get a :
Fatal error: Maximum function nesting level of '100' reached, aborting!
because afterFinds are called repeatedly forever …
so iI was wondering how I could achieve this :
set a custom model property with related model data that also has an afterFind method doing the same with the first model.
I guess I could resort to non AR methods but it would be nice if this was possible and that I just don't know how to do it.
thanks in advance.