124 $this->action =
$query->attrs->action;
125 $this->query_id =
$query->attrs->id;
126 $this->priority =
$query->attrs->priority;
129 if($this->isSubQuery)
131 $this->action =
'select';
136 $this->alias = $dbParser->escape(
$query->attrs->alias);
138 $this->join_type =
$query->attrs->join_type;
159 return $this->query->attrs->query_id ? $this->query->attrs->query_id : $this->query->attrs->id;
164 return $this->query->attrs->priority;
169 return $this->query->attrs->action;
175 if(!isset($this->column_type[
$query_id]))
177 $table_tags =
$tables->getTables();
179 foreach($table_tags as $table_tag)
181 if(is_a($table_tag,
'TableTag'))
183 $table_name = $table_tag->getTableName();
184 $table_alias = $table_tag->getTableAlias();
195 if($this->action ==
'select')
199 else if($this->action ==
'insert' || $this->action ==
'insert-select')
201 return $this->columns =
new InsertColumnsTag($this->query->columns->column);
203 else if($this->action ==
'update')
205 return $this->columns =
new UpdateColumnsTag($this->query->columns->column);
207 else if($this->action ==
'delete')
209 return $this->columns = null;
215 if($this->isSubQuery)
227 $arg_name = $argument->getArgumentName();
231 $prebuff .= $argument->toString();
233 $table_alias = $argument->getTableName();
234 if(isset($table_alias))
236 if(isset($this->column_type[$this->
getQueryId()][$table_alias][$argument->getColumnName()]))
243 $current_tables = $this->column_type[$this->
getQueryId()];
244 $column_name = $argument->getColumnName();
245 foreach($current_tables as $current_table)
247 if(isset($current_table[$column_name]))
256 $prebuff .= sprintf(
'if(${\'%s_argument\'} !== null) ${\'%s_argument\'}->setColumnType(\'%s\');' .
"\n"
266 return $this->preBuff = $prebuff;
272 if($this->isSubQuery)
274 $buff =
'new Subquery(';
275 $buff .=
"'" . $this->alias .
'\',
';
276 $buff .= ($this->columns ? $this->columns->toString() : 'null
' ) . ',
' . PHP_EOL;
277 $buff .= $this->tables->toString() . ',
' . PHP_EOL;
278 $buff .= $this->conditions->toString() . ',
' . PHP_EOL;
279 $buff .= $this->groups->toString() . ',
' . PHP_EOL;
280 $buff .= $this->navigation->getOrderByString() . ',
' . PHP_EOL;
281 $limit = $this->navigation->getLimitString();
282 $buff .= $limit ? $limit : 'null
' . PHP_EOL;
283 $buff .= $this->join_type ? "'" . $this->join_type . "'" : '';
291 $buff .= sprintf('$query->setQueryId(
"%s");%s
', $this->query_id, "\n");
292 $buff .= sprintf('$query->setAction(
"%s");%s
', $this->action, "\n");
293 $buff .= sprintf('$query->setPriority(
"%s");%s
', $this->priority, "\n");
294 $buff .= $this->preBuff;
297 $buff .= '$query->setColumns(
' . $this->columns->toString() . ');
' . PHP_EOL;
300 $buff .= '$query->setTables(
' . $this->tables->toString() . ');
' . PHP_EOL;
301 if($this->action == 'insert-select
')
303 $buff .= '$query->setSubquery(
' . $this->subquery->toString() . ');
' . PHP_EOL;
305 $buff .= '$query->setConditions(
' . $this->conditions->toString() . ');
' . PHP_EOL;
306 $buff .= '$query->setGroups(
' . $this->groups->toString() . ');
' . PHP_EOL;
307 $buff .= '$query->setOrder(
' . $this->navigation->getOrderByString() . ');
' . PHP_EOL;
308 $buff .= '$query->setLimit(
' . $this->navigation->getLimitString() . ');
' . PHP_EOL;
316 if($this->query->index_hint && ($this->query->index_hint->attrs->for == 'ALL
' || Context::getDBType() == strtolower($this->query->index_hint->attrs->for)))
318 return $this->tables = new TablesTag($this->query->tables, $this->query->index_hint);
322 return $this->tables = new TablesTag($this->query->tables);
326 function getSubquery()
328 if($this->query->query)
330 $this->subquery = new QueryTag($this->query->query, true);
334 function getConditions()
336 return $this->conditions = new ConditionsTag($this->query->conditions);
341 if($this->query->groups)
343 return $this->groups = new GroupsTag($this->query->groups->group);
347 return $this->groups = new GroupsTag(NULL);
351 function getNavigation()
353 return $this->navigation = new NavigationTag($this->query->navigation);
361 function getTableString()
366 function getConditionString()
371 function getExpressionString()
376 function getArguments()
378 $arguments = array();
381 $arguments = array_merge($arguments, $this->columns->getArguments());
383 if($this->action == 'insert-select
')
385 $arguments = array_merge($arguments, $this->subquery->getArguments());
387 $arguments = array_merge($arguments, $this->tables->getArguments());
388 $arguments = array_merge($arguments, $this->conditions->getArguments());
389 $arguments = array_merge($arguments, $this->navigation->getArguments());
394 /* End of file QueryTag.class.php */
395 /* Location: ./classes/xml/xmlquery/tags/navigation/QueryTag.class.php */
getTableInfo($query_id, $table_name)
setTableColumnTypes($tables)
__construct($query, $isSubQuery=FALSE)