Beispiel #1
0
 /**
  * \brief Export the schema of the connected ($PG_CONN) database to a
  *        file in the format readable by GetSchema().
  *
  * @param string $filename path to the file to store the schema in.
  *
  * @return false=success, on error return string with error message.
  **/
 function exportSchema($filename = NULL)
 {
     global $PG_CONN;
     /* set driver */
     $dbDriver = $this->dbman->getDriver();
     if (empty($dbDriver)) {
         $this->dbman->setDriver(new Postgres($PG_CONN));
     }
     if (empty($filename)) {
         $filename = stdout;
     }
     $Schema = $this->getCurrSchema();
     $fout = fopen($filename, "w");
     if (!$fout) {
         return "Failed to write to {$filename}\n";
     }
     global $Name;
     fwrite($fout, "<?php\n");
     fwrite($fout, "/* This file is generated by " . $Name . " */\n");
     fwrite($fout, "/* Do not manually edit this file */\n\n");
     fwrite($fout, '  $Schema=array();' . "\n\n");
     foreach ($Schema as $K1 => $V1) {
         $this->writeArrayEntries($fout, $K1, $V1, '  $Schema');
     }
     fclose($fout);
     return false;
 }