/**
  * Install schema into the database
  *
  * @param string $filename location of database schema file
  * @param dbconn $conn     connection to database
  * @param string $type     type of database, currently mysql or pgsql
  *
  * @return boolean - indicating success or failure
  */
 function runDbScript($filename, $conn, $type = 'mysqli')
 {
     $sql = trim(file_get_contents(INSTALLDIR . '/db/' . $filename));
     $stmts = explode(';', $sql);
     foreach ($stmts as $stmt) {
         $stmt = trim($stmt);
         if (!mb_strlen($stmt)) {
             continue;
         }
         // FIXME: use PEAR::DB or PDO instead of our own switch
         switch ($type) {
             case 'mysqli':
                 $res = $conn->query($stmt);
                 if ($res === false) {
                     $error = $conn->error();
                 }
                 break;
             case 'pgsql':
                 $res = pg_query($conn, $stmt);
                 if ($res === false) {
                     $error = pg_last_error();
                 }
                 break;
             default:
                 $this->updateStatus("runDbScript() error: unknown database type " . $type . " provided.");
         }
         if ($res === false) {
             $this->updateStatus("ERROR ({$error}) for SQL '{$stmt}'");
             return $res;
         }
     }
     return true;
 }