public function testSaveToString() { $xmldoc = new TXmlDocument('1.0', 'utf-8'); $xmldoc->setTagName('root'); $node = new TXmlElement('node'); $node->setAttribute('param', 'attribute1'); $xmldoc->getElements()->add($node); $xmlString = $xmldoc->saveToString(); // test magic method $magicString = (string) $xmldoc; self::assertEquals($magicString, $xmlString); // Result string should be : $resultString = "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<root>\n <node param=\"attribute1\"\n</root>"; self::assertEquals($xmlString, $magicString); }
/** * @return string Return the database dump * @soapmethod */ public function syncDatabaseData() { $app = Prado::getApplication(); $db = $app->getModule('horuxDb')->DbConnection; $db->setAttribute(PDO::MYSQL_ATTR_USE_BUFFERED_QUERY, true); $db->Active = true; $cmd = $db->createCommand("SELECT * FROM hr_trigger_change ORDER BY id"); $data = $cmd->query(); $data = $data->readAll(); $doc = new TXmlDocument('1.0', 'utf-8'); $doc->TagName = 'SyncData'; foreach ($data as $row) { $trigger = new TXmlElement('Trigger'); $trigger->setAttribute('id', $row['id']); $doc->Elements[] = $trigger; $table = new TXmlElement('table'); $table->setAttribute('name', $row['table']); $table->setAttribute('action', $row['action']); $table->setAttribute('key', $row['key']); $trigger->Elements[] = $table; $newValue = new TXmlElement('newValue'); $newValue->Value = $row['newValue']; $table->Elements[] = $newValue; } return $doc->saveToString(); }