/**
  * Creates a DOM document containing data for specified database.
  * @param      Database $database
  * @return     DOMDocument
  */
 private function createXMLDoc(DatabasePropel $database)
 {
     $doc = new DOMDocument('1.0', 'utf-8');
     $doc->formatOutput = true;
     // pretty printing
     $doc->appendChild($doc->createComment("Created by data/dump/Control.tpl template."));
     $dsNode = $doc->createElement("dataset");
     $dsNode->setAttribute("name", "all");
     $doc->appendChild($dsNode);
     $this->log("Building DOM tree containing data from tables:");
     foreach ($database->getTables() as $tbl) {
         $this->log("\t+ " . $tbl->getName());
         $rs = $this->getTableDataRS($tbl->getName());
         while ($rs->next()) {
             $rowNode = $doc->createElement($tbl->getPhpName());
             foreach ($tbl->getColumns() as $col) {
                 $cval = $rs->get($col->getName());
                 if ($cval !== null) {
                     $rowNode->setAttribute($col->getPhpName(), iconv($this->dbEncoding, 'utf-8', $cval));
                 }
             }
             $dsNode->appendChild($rowNode);
             unset($rowNode);
         }
         $rs->close();
     }
     return $doc;
 }
Example #2
0
 protected function cloneDatabase($db)
 {
     $attributes = array('name' => $db->getName(), 'baseClass' => $db->getBaseClass(), 'basePeer' => $db->getBasePeer(), 'defaultIdMethod' => $db->getDefaultIdMethod(), 'defaultPhpNamingMethod' => $db->getDefaultPhpNamingMethod(), 'defaultTranslateMethod' => $db->getDefaultTranslateMethod());
     $clone = new DatabasePropel();
     $clone->loadFromXML($attributes);
     return $clone;
 }
Example #3
0
 /**
  * Add a database to the list and sets the AppData property to this
  * AppData
  *
  * @param      db the database to add
  */
 public function addDatabase($db)
 {
     if ($db instanceof DatabasePropel) {
         $db->setAppData($this);
         if ($db->getPlatform() === null) {
             $db->setPlatform($this->platform);
         }
         $this->dbList[] = $db;
         return $db;
     } else {
         // XML attributes array / hash
         $d = new DatabasePropel();
         $d->loadFromXML($db);
         return $this->addDatabase($d);
         // calls self w/ different param type
     }
 }