Database query failure! (multiple datasources)
| From: | Casey Allen Shobe | Date: | Thu, 31 Jan 2002 00:26:09 +0000 |
| Subject: | Database query failure! (multiple datasources) | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-82850@lists.php.net to get a copy of this message | ||
Ok. Here's the deal...I have two databases that I access via ODBC, DB2, and
MSSQL, through unixODBC.
If I run MSSQL queries before DB2 queries, everything works fine.
If I run DB2 queries before MSSQL queries, only the DB2 queries are
successful, and the MSSQL query returns an empty array.
I need to sometimes use either order.
$db2_alias = 'sw_p';
$db2_username = 'db2inst1';
$db2_passwd = 'xxxxxxxx';
$db2_conn = odbc_connect ($db2_alias, $db2_username, $db2_passwd);
$piv_alias = 'pivotal';
$piv_username = 'cshobe';
$piv_passwd = 'xxxxxxxx';
$piv_conn = odbc_connect ($piv_alias, $piv_username, $piv_passwd);
function db_query($db_conn, $db_query) {
$result = odbc_exec($db_conn, $db_query);
$data[0] = get_data ($result);
$data[1] = odbc_num_rows ($result);
odbc_free_result ($result);
return $data;
}
$num_queue_alerts = db_query ($db2_conn, 'select count(*) from alerts where
egad=-1');
$company_name = db_query ($piv_conn, 'select company.company_name from
registration,company where company.company_id=registration_id and
registration.sw_nibc=\'955\'');
echo $num_queue_alerts.$company_name;
If I execute the above, the output is '15Secureworks'. If I put the query
lines in this order:
$company_name = db_query ($piv_conn, 'select company.company_name from
registration,company where company.company_id=registration_id and
registration.sw_nibc=\'955\'');
$num_queue_alerts = db_query ($db2_conn, 'select count(*) from alerts where
egad=-1');
...then the output is '15'. What is the logic here? I see none... Does
anyone else use multiple data sources?
--
Casey Allen Shobe
cshobe@softhome.net