I have a RHEL server Linux-Apache-PHP plus some separate Microsoft SQL Server 2008R2, that I access via FreeTDS. I would like to open two separate connections, from inside a PHP script, which may go to the same SQL Server, or to two different servers. When the two servers are the same, I encounter a problem.
$MyConn1 = mssql_connect( $ServerName, $User, $Password ) ;
$MyConn2 = mssql_connect( $ServerName, $User, $Password ) ;
print_r( $MyConn1 ) ; print "\n" ;
print_r( $MyConn2 ) ; print "\n" ;
mssql_select_db( "DB1", $MyConn1 ) ;
mssql_select_db( "DB2", $MyConn2 ) ;
$MyReturn = mssql_query( 'select db_name()', $MyConn1 ) ;
$t = mssql_fetch_row( $MyReturn ) ;
print $t[ 0 ] ;
The output is:
Resource id #2
Resource id #2
DB2
So, even if I make two separate calls, they return only one connection. Is it possible to have two separate connections, pointing to the same server?
What I need to do is a table copy procedure, that receives the connection details from a configuration file, and that works both when the two servers are distinct and when they are the same.