/**
  * Connect to the MySQL data source, looks for the following
  * configuration options.
  * <ul>
  *   <li>server - The hostname or IP address of the MySQL DB
  *   server.</li>
  *   <li>username - The username on the MySQL database.</li>
  *   <li>password - The password on the MySQL database.</li>
  * </ul>
  * @return TRUE is successful, FALSE otherwise (though this is
  * unlikely to occur because of the fatal error event when the
  * connection fails).
  */
 function connect()
 {
     if (!parent::connect()) {
         $username = $this->config->get('username');
         if (!is_string($username)) {
             $username = get_current_user();
             $this->config->warn("MySQL username is not specified, using the user " . "of the PHP process ({$username}).  This may be " . "ambiguous, consider setting the 'username' " . "configuration option.");
         }
         if (!($this->myLink = mysql_connect($this->config->get('server'), $username, $this->config->get('password')))) {
             LogFatal("Unable to establish MySQL connetion: " . mysql_error());
             return FALSE;
         }
         $database = $this->config->get('database');
         if (!is_string($database)) {
             $this->config->warn("MySQL database name is not specified, using the " . "username ({$username}) as the database name.  This " . "may be ambiguous, consider setting the 'database' " . "configuration option.");
             $database = $username;
         }
         if (!mysql_select_db($database, $this->myLink)) {
             LogFatal("Unable to select MySQL database: " . mysql_error());
             return FALSE;
         }
     }
     return TRUE;
 }
 /**
  * "Connect" to the user input.
  * @return TRUE is successful, FALSE otherwise.
  */
 function connect()
 {
     if (!parent::connect()) {
         return !is_null($_REQUEST);
     }
     return TRUE;
 }
Exemple #3
0
 /**
  * Import data from a data source into this object's change set.
  * @param DataSource $ds alternate data source to use.
  */
 function import(&$ds)
 {
     $ds->connect();
     $this->storage_method->import($this, $ds);
 }