Squiz Matrix  4.12.2
 All Data Structures Namespaces Functions Variables Pages
DALWithParser.inc
1 <?php
13 require_once 'DAL/Parsers/DALQueryParser.inc';
14 require_once 'DAL/Parsers/DALSelectParser.inc';
15 require_once 'DAL/Parsers/DALWhereParser.inc';
16 require_once 'DAL/Parsers/DALUnionParser.inc';
17 
26 {
27 
28 
36  private function __construct()
37  {
38 
39  }//end __construct()
40 
41 
59  public static function parse(DomElement $xmlQuery)
60  {
61  $query = array();
62  $withTag = $xmlQuery->getElementsByTagName('with')->item(0);
63 
64  $query['WITH'] = self::parseSqlFunction($withTag);
65 
66  // Find the select.
67  $query['WITH'] = array_merge($query['WITH'], DALUnionParser::parse($withTag));
68 
69  $after = $withTag->getElementsByTagName('after')->item(0);
70 
71  $query['WITH']['AFTER'] = DALSelectParser::parse($after);
72 
73  $connectBy = $withTag->getElementsByTagName('connect-by-prior')->item(0);
74 
75  $query['WITH']['CONNECT-BY-PRIOR'] = current(DALWhereParser::parse($connectBy->parentNode, 'connect-by-prior'));
76 
77  return $query;
78 
79  }//end parse()
80 
81 
90  public static function validate(DomElement $xmlQuery)
91  {
92 
93  }//end validate()
94 
95 
113  protected static function parseSqlFunction(DomElement $function)
114  {
115  $query = array();
116  $query['FUNCTION'] = array();
117  $query['FUNCTION']['function'] = $function->getAttribute('function');
118  $query['FUNCTION']['ARGS'] = array();
119 
120  if ($function->getAttribute('alias') !== '') {
121  $query['FUNCTION']['alias'] = $function->getAttribute('alias');
122  }
123 
124  $argsTag = $function->getElementsByTagName('args')->item(0);
125  $argTags = $argsTag->getElementsByTagName('arg');
126 
127  foreach ($argTags as $arg) {
128  $query['FUNCTION']['ARGS'][] = $arg->nodeValue;
129  }
130 
131  return $query;
132 
133  }//end parseSqlFunction()
134 
135 
136 }//end class
137 
138 ?>