/** * Lazy load a many-to-many relationship * * @param string $property The property that we are trying to load * * @return BaseEntityAbstract */ protected function loadManyToMany($property) { // Grab the DaoMap data for both ends of the join $this->__loadDaoMap(); $cls = DaoMap::$map[strtolower(get_class($this))][$property]['class']; $obj = new $cls(); $obj->__loadDaoMap(); $thisClass = get_class($this); $qry = new DaoQuery($cls); $qry->eagerLoad($cls . '.' . strtolower(substr($thisClass, 0, 1)) . substr($thisClass, 1) . 's'); // Load this end with an array of entities typed to the other end DaoMap::loadMap($cls); $alias = DaoMap::$map[strtolower($cls)]['_']['alias']; $field = strtolower(substr($thisClass, 0, 1)) . substr($thisClass, 1); $this->{$property} = Dao::findByCriteria($qry, sprintf('`%sId`=?', $field), array($this->getId())); return $this; }