/** * Builds SQL statement from 'variable' node * * The returning array is an associative array keyed by the primitive * variable in the form of '<alias>.<var_name>' and the value is the * condition for the relationship fields. * * @return false|array * @throws epExceptionQueryBuilder */ protected function buildSqlVariable(epQueryNode &$node) { // check if path is set on variable node if (!($path = trim($node->getParam('path')))) { throw new epExceptionQueryBuilder($this->_e("no path for varialbe", $node)); return false; } // the varialbe name is the last item $pieces = explode('.', $path); $var = $pieces[count($pieces) - 1]; // array to hold SQL expressions for primitive vars $pvars = array(); // if the path points to an object if ($this->pm->isObject($path)) { // force it to oid $var = 'oid'; } // call path manager to get aliases if ($aliases = $this->pm->getAliases($path)) { foreach ($aliases as $alias) { $pvars[] = $this->pm->quoteId($alias) . '.' . $this->pm->quoteId($var); } } return $pvars; }