Ejemplo n.º 1
0
 /**
  * create the empty database
  *
  * @return boolean
  */
 function _createDatabase($aDsn = '')
 {
     if ($aDsn) {
         $this->aDsn = $aDsn;
     }
     $GLOBALS['_MAX']['CONF']['database'] = $this->aDsn['database'];
     $GLOBALS['_MAX']['CONF']['table']['prefix'] = $this->aDsn['table']['prefix'];
     $GLOBALS['_MAX']['CONF']['table']['type'] = $this->aDsn['table']['type'];
     // Try connecting to the database
     $this->oDbh =& OA_DB::singleton(OA_DB::getDsn($this->aDsn));
     if (PEAR::isError($this->oDbh)) {
         $GLOBALS['_OA']['CONNECTIONS'] = array();
         $GLOBALS['_MDB2_databases'] = array();
         if (PEAR::isError($result)) {
             $this->oLogger->logError($result->getMessage());
             $this->oLogger->logErrorUnlessEmpty($result->getUserInfo());
             return false;
         }
         //attempt to create DB
         $result = OA_DB::createDatabase($this->aDsn['database']['name']);
         if (PEAR::isError($result)) {
             $this->oLogger->logError($result->getMessage());
             $this->oLogger->logErrorUnlessEmpty($result->getUserInfo());
             return false;
         }
         $this->oDbh = OA_DB::changeDatabase($this->aDsn['database']['name']);
         if (PEAR::isError($this->oDbh)) {
             $this->oLogger->logError($this->oDbh->getMessage());
             $this->oLogger->logErrorUnlessEmpty($this->getUserInfo());
             $this->oDbh = null;
             return false;
         }
         $this->oLogger->log('Database created ' . $this->aDsn['database']['name']);
         $this->can_drop_database = true;
     }
     $result = OA_DB::createFunctions();
     if (PEAR::isError($result)) {
         $this->oLogger->logError($result->getMessage());
         return false;
     }
     return true;
 }