Squiz Matrix  4.12.2
 All Data Structures Namespaces Functions Variables Pages
DALUnionParser.inc
1 <?php
13 require_once 'DAL/Parsers/DALQueryParser.inc';
14 require_once 'DAL/Parsers/DALSelectParser.inc';
15 require_once 'DAL/DALBaker.inc';
16 
25 {
26 
27 
36  private function __construct()
37  {
38 
39  }//end __construct()
40 
41 
58  public static function parse(DomElement $xmlQuery)
59  {
60  // Find out which type of union this is.
61  $query = array();
62  $unionTag = $xmlQuery->getElementsByTagName('union')->item(0);
63  if ($unionTag === NULL) {
64  $unionTag = $xmlQuery->getElementsByTagName('union-all')->item(0);
65  if ($unionTag === NULL) {
66  return $query;
67  }
68  }
69 
70  // UNION or UNION-ALL.
71  $tag = strtoupper($unionTag->tagName);
72  $query[$tag] = array();
73 
74  // Get the alias if there is one.
75  if ($unionTag->getAttribute('alias') !== '') {
76  $query[$tag]['alias'] = $unionTag->getAttribute('alias');
77  }
78 
79  $query[$tag]['SELECTS'] = array();
80 
81  // Get all select Tags inside union.
82  foreach ($unionTag->childNodes as $node) {
83  if ($node->nodeType !== XML_ELEMENT_NODE) {
84  continue;
85  }
86 
87  if ($node->tagName === 'select') {
88  $query[$tag]['SELECTS'][] = DALSelectParser::parse($node);
89  } else if ($node->tagName === 'hook') {
90  $hookid = DALBaker::getHookPrefix().$node->getAttribute('id');
91  $query[$tag]['SELECTS'][] = $hookid;
92  }
93  }
94 
95  return $query;
96 
97  }//end parse()
98 
99 
108  public static function validate(DomElement $query)
109  {
110 
111  }//end validate()
112 
113 
114 }//end class
115 
116 ?>