protected function doListAll(VF_Level $entity, $parent_id = 0) { $select = $this->getReadAdapter()->select()->from(array('l' => $entity->getTable()))->order('title')->group('l.title'); if (is_numeric($parent_id) && $parent_id > 0 && $entity->getPrevLevel()) { $select->joinLeft(array('d' => $this->getSchema()->definitionTable()), 'l.id = d.' . $entity->getType() . '_id', array())->where('d.' . $entity->getPrevLevel() . '_id = ?', $parent_id); } if (is_array($parent_id) && $entity->getPrevLevel()) { $select->joinLeft(array('d' => $this->getSchema()->definitionTable()), 'l.id = d.' . $entity->getType() . '_id', array()); foreach ($parent_id as $level => $each_parent_id) { if (!in_array($level, $this->getSchema()->getLevels(), true)) { throw new VF_Level_Exception_InvalidLevel('Invalid level [' . $level . ']'); } $select->where('d.' . $level . '_id = ?', $each_parent_id); } } $result = $select->query(); $this->objs[$entity->getType()][$entity->getId()] = array(); foreach ($result->fetchAll(Zend_Db::FETCH_OBJ) as $row) { $obj = $this->find($entity->getType(), $row->id); array_push($this->objs[$entity->getType()][$entity->getId()], $obj); } return $this->objs[$entity->getType()][$entity->getId()]; }