/** * Preprocess on the from clause to add super and secondary roots * @return boolean * @throws epExceptionQueryBuilder */ private function processFrom() { // check if we have already done? (if done, root alias must have been set.) if ($this->primary_alias) { return true; } // get from node if (!($from = $this->root->getChild('from'))) { throw new epExceptionQueryBuilder($this->_e("cannot found 'from' clause")); return false; } // get from items if (!($items = $from->getChildren())) { throw new epExceptionQueryBuilder($this->_e("no 'from' items specified")); return false; } // get the super root (the 1st) from 'from' items $item = array_shift($items); // add the super root $this->primary_class = $item->getParam('class'); $this->primary_alias = $item->getParam('alias'); $this->pm->addPrimaryRoot($this->primary_class, $this->primary_alias); // go through the rest: secondary roots foreach ($items as &$item) { // get class from item $class = $item->getParam('class'); // a secondary root must have alias assigned if (!($alias = $item->getParam('alias'))) { // skip if not throw new epExceptionQueryBuilder($this->_e("no alias defined for class [{$class}]")); continue; } // keep track of aliases for secondary $this->aliases_secondary[] = $alias; // add class as a secondary root $this->pm->addSecondaryRoot($class, $alias); } return true; }