public function indexAction() { $node = $this->root->appendChild($this->xml->createElement('database')); // stats/mysql /** @var \DOMElement $mysqlNode */ $mysqlNode = $node->appendChild($this->xml->createElement('mysql')); try { \Difra\MySQL\Parser::getStatusXML($mysqlNode); } catch (Exception $ex) { $mysqlNode->setAttribute('error', $ex->getMessage() . ': ' . \Difra\MySQL::getInstance()->getError()); } // stats of Unify tables $unifyNode = $node->appendChild($this->xml->createElement('unify')); \Difra\Unify\DBAPI::getDbStatusXML($unifyNode); }
/** * @param \DOMElement $node */ public function getStatusXML($node) { /** @var $statusNode \DOMElement */ $statusNode = $node->appendChild($node->ownerDocument->createElement('table')); $statusNode->setAttribute('name', $this->name); if (empty($this->definitions)) { $statusNode->setAttribute('nodef', 1); return; } if (empty($this->goal)) { $statusNode->setAttribute('nogoal', 1); return; } $current = []; foreach ($this->definitions as $def) { $current[] = Parser::def2string($def); } $goal = []; foreach ($this->goal as $g) { $goal[] = Parser::def2string($g); } $diff = Diff::diffArrays($current, $goal); if (is_array($diff) and !empty($diff)) { $haveDiff = false; foreach ($diff as $d) { if ($d['sign'] != '=') { $haveDiff = true; break; } } if (!$haveDiff) { return; } $statusNode->setAttribute('diff', 1); foreach ($diff as $d) { /** @var $diffNode \DOMElement */ $diffNode = $statusNode->appendChild($node->ownerDocument->createElement('diff')); @$diffNode->setAttribute('sign', $d['sign']); @$diffNode->setAttribute('value', $d['value']); } } }