mirror of
https://github.com/dg/dibi.git
synced 2025-03-13 19:00:05 +01:00
DibiMsSql2005Driver: added config aliases 'username', 'password', 'database'
This commit is contained in:
parent
550c477797
commit
0748c693ff
@ -16,6 +16,9 @@
|
||||
*
|
||||
* Connection options:
|
||||
* - '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}
|
||||
* - 'lazy' - if TRUE, connection will be established only when required
|
||||
* - 'charset' - character encoding to set (default is UTF-8)
|
||||
@ -53,14 +56,15 @@ class DibiMsSql2005Driver extends DibiObject implements IDibiDriver
|
||||
*/
|
||||
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'])) {
|
||||
$this->connection = $config['resource'];
|
||||
|
||||
} elseif (isset($config['options'])) {
|
||||
$this->connection = sqlsrv_connect($config['host'], (array) $config['options']);
|
||||
|
||||
} else {
|
||||
$this->connection = sqlsrv_connect($config['host']);
|
||||
$this->connection = sqlsrv_connect($config['host'], (array) $config['options']);
|
||||
}
|
||||
|
||||
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
|
||||
echo '<p>Connecting to Oracle: ';
|
||||
try {
|
||||
|
Loading…
x
Reference in New Issue
Block a user