protected function MigrateSourceMSSQL::connect in Migrate 7.2
Same name and namespace in other branches
- 6.2 plugins/sources/mssql.inc \MigrateSourceMSSQL::connect()
Connect lazily to the DB server.
2 calls to MigrateSourceMSSQL::connect()
- MigrateSourceMSSQL::computeCount in plugins/
sources/ sqlsrv.inc - Return a count of all available source records.
- MigrateSourceMSSQL::performRewind in plugins/
sources/ sqlsrv.inc - Implementation of MigrateSource::performRewind().
File
- plugins/
sources/ sqlsrv.inc, line 87 - 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('sqlsrv')) {
throw new Exception(t('You must configure the sqlsrv extension in PHP.'));
}
if (isset($this->configuration['port'])) {
$host = $this->configuration['servername'] . ',' . $this->configuration['port'];
}
else {
$host = $this->configuration['servername'];
}
$connectionInfo = array(
"Database" => $this->configuration['database'],
"UID" => $this->configuration['username'],
"PWD" => $this->configuration['password'],
);
// Add CharacterSet option.
if (!empty($this->configuration['character_set'])) {
$connectionInfo["CharacterSet"] = $this->configuration['character_set'];
}
$this->connection = sqlsrv_connect($host, $connectionInfo);
if ($this->connection !== FALSE) {
return $this->connection;
}
}
}