You are here

protected function MigrateSourceMSSQL::connect in Migrate 6.2

Same name and namespace in other branches
  1. 7.2 plugins/sources/sqlsrv.inc \MigrateSourceMSSQL::connect()

Connect lazily to the DB server.

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

File

plugins/sources/mssql.inc, line 86
Define a MigrateSource for importing from Microsoft SQL Server databases.

Class

MigrateSourceMSSQL
Implementation of MigrateSource, to handle imports from remote MS SQL Server db servers.

Code

protected function connect() {
  if (!isset($this->connection)) {
    if (!extension_loaded('mssql')) {
      throw new Exception(t('You must configure the mssql extension in PHP.'));
    }
    if (isset($this->configuration['port'])) {
      $host = $this->configuration['servername'] . ':' . $this->configuration['port'];
    }
    else {
      $host = $this->configuration['servername'];
    }
    $this->connection = mssql_connect($host, $this->configuration['username'], $this->configuration['password'], TRUE);
    if (isset($this->configuration['database'])) {
      return mssql_select_db($this->configuration['database'], $this->connection);
    }
  }
}