• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Set multiple connections for mssql dbs?

#1
[eluser]ArthurHacker[/eluser]
I can't even set multiple connections for MSSQL Server. I've found an article on this forum where had been described how to set multiple connections, but it didn't work well for me - the mssql_query statement throws an error that the link identifier is not the MSSQL-Link resource etc. I've done something like this: 1) set the database.php - database configuration file:
Code:
$active_group = 'suburb';
$active_record = FALSE;

$db['suburb']['hostname'] = 'XXXXXXXX';
$db['suburb']['username'] = 'XXXX';
$db['suburb']['password'] = 'XXXXXXX';
$db['suburb']['database'] = 'XXXXXXX';
$db['suburb']['dbdriver'] = 'mssql';
$db['suburb']['dbprefix'] = '';
$db['suburb']['pconnect'] = TRUE;
$db['suburb']['db_debug'] = TRUE;
$db['suburb']['cache_on'] = FALSE;
$db['suburb']['cachedir'] = '';
$db['suburb']['char_set'] = 'utf8';
$db['suburb']['dbcollat'] = 'utf8_general_ci';
$db['suburb']['swap_pre'] = '';
$db['suburb']['autoinit'] = TRUE;
$db['suburb']['stricton'] = FALSE;

$active_group = 'default';
$active_record = FALSE;

$db['default']['hostname'] = 'XXXXXX';
$db['default']['username'] = 'XXXX';
$db['default']['password'] = 'XXXXXXXX';
$db['default']['database'] = 'XXXXXX';
$db['default']['dbdriver'] = 'mssql';
$db['default']['dbprefix'] = '';
$db['default']['pconnect'] = TRUE;
$db['default']['db_debug'] = TRUE;
$db['default']['cache_on'] = FALSE;
$db['default']['cachedir'] = '';
$db['default']['char_set'] = 'utf8';
$db['default']['dbcollat'] = 'utf8_general_ci';
$db['default']['swap_pre'] = '';
$db['default']['autoinit'] = TRUE;
$db['default']['stricton'] = FALSE;
2) call the load dbs function:

Code:
$this->suburbDb = $this->load->database('suburb', true);
$this->load->database('default', true);
Note: if I try to set default db 1-st then it crashes.
3) created the query:

Code:
$res = mssql_query(" SELECT TOP 100 ID FROM Table", $this->suburbDb);

The CI error message is:
Message: mssql_query(): supplied argument is not a valid MS SQL-Link resource

So what is the problem? Please help.


Messages In This Thread
Set multiple connections for mssql dbs? - by El Forum - 07-11-2011, 02:36 AM
Set multiple connections for mssql dbs? - by El Forum - 07-11-2011, 09:32 AM
Set multiple connections for mssql dbs? - by El Forum - 07-11-2011, 11:23 AM

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2021 MyBB Group.