mirror of
https://github.com/dg/dibi.git
synced 2025-08-04 13:17:58 +02:00
DibiMsSql2005Driver: added config aliases 'username', 'password', 'database'
This commit is contained in:
@@ -16,6 +16,9 @@
|
|||||||
*
|
*
|
||||||
* Connection options:
|
* Connection options:
|
||||||
* - 'host' - the MS SQL server host name. It can also include a port number (hostname:port)
|
* - 'host' - the MS SQL server host name. It can also include a port number (hostname:port)
|
||||||
|
* - 'username'
|
||||||
|
* - 'password'
|
||||||
|
* - 'database' - the database name to select
|
||||||
* - 'options' - connection info array {@link http://msdn.microsoft.com/en-us/library/cc296161(SQL.90).aspx}
|
* - 'options' - connection info array {@link http://msdn.microsoft.com/en-us/library/cc296161(SQL.90).aspx}
|
||||||
* - 'lazy' - if TRUE, connection will be established only when required
|
* - 'lazy' - if TRUE, connection will be established only when required
|
||||||
* - 'charset' - character encoding to set (default is UTF-8)
|
* - 'charset' - character encoding to set (default is UTF-8)
|
||||||
@@ -53,14 +56,15 @@ class DibiMsSql2005Driver extends DibiObject implements IDibiDriver
|
|||||||
*/
|
*/
|
||||||
public function connect(array &$config)
|
public function connect(array &$config)
|
||||||
{
|
{
|
||||||
|
DibiConnection::alias($config, 'options|UID', 'username');
|
||||||
|
DibiConnection::alias($config, 'options|PWD', 'password');
|
||||||
|
DibiConnection::alias($config, 'options|Database', 'database');
|
||||||
|
|
||||||
if (isset($config['resource'])) {
|
if (isset($config['resource'])) {
|
||||||
$this->connection = $config['resource'];
|
$this->connection = $config['resource'];
|
||||||
|
|
||||||
} elseif (isset($config['options'])) {
|
|
||||||
$this->connection = sqlsrv_connect($config['host'], (array) $config['options']);
|
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
$this->connection = sqlsrv_connect($config['host']);
|
$this->connection = sqlsrv_connect($config['host'], (array) $config['options']);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!is_resource($this->connection)) {
|
if (!is_resource($this->connection)) {
|
||||||
|
@@ -128,6 +128,25 @@ echo "</p>\n";
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// connects to MS SQL 2005
|
||||||
|
echo '<p>Connecting to MS SQL 2005: ';
|
||||||
|
try {
|
||||||
|
dibi::connect(array(
|
||||||
|
'driver' => 'mssql2005',
|
||||||
|
'host' => '(local)',
|
||||||
|
'username' => 'Administrator',
|
||||||
|
'password' => 'xxx',
|
||||||
|
'database' => 'main',
|
||||||
|
));
|
||||||
|
echo 'OK';
|
||||||
|
|
||||||
|
} catch (DibiException $e) {
|
||||||
|
echo get_class($e), ': ', $e->getMessage(), "\n";
|
||||||
|
}
|
||||||
|
echo "</p>\n";
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// connects to Oracle
|
// connects to Oracle
|
||||||
echo '<p>Connecting to Oracle: ';
|
echo '<p>Connecting to Oracle: ';
|
||||||
try {
|
try {
|
||||||
|
Reference in New Issue
Block a user