You are here

protected function MigrateSourceDB2::connect in Migrate 7.2

Connect lazily to the DB server.

2 calls to MigrateSourceDB2::connect()
MigrateSourceDB2::computeCount in plugins/sources/db2.inc
Return a count of all available source records.
MigrateSourceDB2::performRewind in plugins/sources/db2.inc
Implementation of MigrateSource::performRewind().

File

plugins/sources/db2.inc, line 79
Define a MigrateSource class for importing from IBM DB2 databases.

Class

MigrateSourceDB2
Implementation of MigrateSource, to handle imports from remote DB2 servers.

Code

protected function connect() {
  if (!isset($this->connection)) {

    // Check for the ibm_db2 extension before attempting to connect with it.
    if (!extension_loaded('ibm_db2')) {
      throw new Exception(t('You must configure the ibm_db2 extension in PHP.'));
    }

    // Connect to db2.
    $this->connection = db2_connect($this->configuration['database'], $this->configuration['username'], $this->configuration['password']);
  }
  if ($this->connection) {
    return TRUE;
  }
  else {
    $e = db2_conn_errormsg();
    throw new Exception($e);
    return FALSE;
  }
}