Пример #1
0
 /**
  * Treats a <data type="sql:subquery"> node and its <data> and <where> children
  *
  * @param  SimpleXmlElement $data
  * @param  boolean          $suppressAs  [optional] if true, do not output the AS statement (e.g. if used inside formulas it's not allowed)
  * @return string
  */
 protected function process_subquery($data, $suppressAs = false)
 {
     $subqueryData = $data->getChildByNameAttributes('data');
     $subqueryTable = $subqueryData->attributes('table');
     $subqueryName = $subqueryData->attributes('name');
     $queryAs = $data->attributes('as');
     $this->_levelPush();
     $this->incrementTableAs();
     $xmlsql = new self($this->_db, $subqueryTable, $this->_pluginParams);
     $xmlsql->syncSubQueryTablesIndexes($this);
     //		$xmlsql->_currentTableAs	=	$this->tableAs;
     $xmlsql->maintableAs = $this->tableAs;
     //		$xmlsql->_table				=	$subqueryTable;
     $xmlsql->process_data($subqueryData);
     $childrenFormulas = '( ' . $xmlsql->_buildSQLquery() . ' )' . (($queryAs || $subqueryName) && !$suppressAs ? ' AS ' . $this->_db->NameQuote($queryAs ? $queryAs : $subqueryName) : '');
     $this->_levelPop();
     return $childrenFormulas;
 }