13 require_once
'DAL/Parsers/DALQueryParser.inc';
14 require_once
'DAL/Parsers/DALWhereParser.inc';
15 require_once
'XML/XML.inc';
36 private function __construct()
57 public static function parse(DomElement $xmlQuery)
61 $updateTag = $xmlQuery->getElementsByTagName(
'update')->item(0);
62 if ($updateTag !== NULL) {
63 $query[
'UPDATE'] = array();
66 $fieldsTag = $updateTag->getElementsByTagName(
'fields')->item(0);
67 if ($fieldsTag !== NULL) {
68 $query[
'UPDATE'][
'table'] = $fieldsTag->getAttribute(
'table');
71 $fields = $fieldsTag->getElementsByTagName(
'field');
72 foreach ($fields as $field) {
73 $qfields[] = $field->nodeValue;
77 $query[
'UPDATE'][
'FIELDS'] = $qfields;
80 $valuesTag = $updateTag->getElementsByTagName(
'values')->item(0);
83 foreach ($valuesTag->childNodes as $value) {
84 if ($value->nodeType === XML_ELEMENT_NODE) {
85 $vCol = $value->getAttribute(
'column');
89 $qvals[$vCol] = $value->nodeValue;
94 $query[
'UPDATE'][
'VALUES'] = $qvals;
98 $query[
'UPDATE'] = array_merge($query[
'UPDATE'], $where);
122 $updateTag = $query->getElementsByTagName(
'update')->item(0);
123 if ($updateTag === NULL) {
128 $fieldsTag = $updateTag->getElementsByTagName(
'fields');
129 if ($fieldsTag->length !== 0) {
130 $fieldsTag = $fieldsTag->item(0);
131 $parentTagName = $fieldsTag->parentNode->tagName;
136 if (($fieldsTag === NULL) || ($parentTagName !==
'update')) {
137 $msg =
'Update query must have fields tag.';
141 self::validateFieldsTag($fieldsTag);
143 $valuesTag = $updateTag->getElementsByTagName(
'values')->item(0);
144 if ($valuesTag === NULL) {
145 $msg =
'Update query must have values tag.';
149 self::validateValuesTag($valuesTag);
151 $whereTag = $updateTag->getElementsByTagName(
'where')->item(0);
152 if ($whereTag !== NULL) {