|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2004-09-16 15:42 UTC] vrana@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Wed Nov 19 12:00:02 2025 UTC |
Description: ------------ The documentation of odbc_data_source suggests that the information about the current connection will be used to provide the server and the description as part of the results. This is NOT the case. The function odbc_data_source returns information for all DSNs defined. I am not sure if the bug is in the manual or the function. The reason I say "suggest" is that you have to provide a connection. Reproduce code: --------------- From the example in the user notes. <?php // Example usage: // Connect to a ODBC database that exists on your system $link = odbc_connect("HRUnityOnline", "CARVAL_USER", "pswd") or die(odbc_errormsg() ); $result = @odbc_data_source( $link, SQL_FETCH_FIRST ); while($result) { echo "DSN: " . $result['server'] . " - " . $result['description'] . "<br>\n"; $result = @odbc_data_source( $link, SQL_FETCH_NEXT ); } odbc_close($link); ?> Expected result: ---------------- DSN: HRUnityOnline - SQL Server To acheive the desired result (i.e. you want to see the type of server type for the current DSN) ... <?php // Example usage: $sDSN = "HRUnityOnline"; // Connect to a ODBC database that exists on your system $link = odbc_connect($sDSN, "CARVAL_USER", "pswd") or die(odbc_errormsg() ); $result = @odbc_data_source( $link, SQL_FETCH_FIRST ); while($result) { if ($result['server'] == $sDSN) { echo "DSN: " . $result['server'] . " - " . $result['description'] . "<br>\n"; break; } $result = @odbc_data_source( $link, SQL_FETCH_NEXT ); } odbc_close($link); ?> Actual result: -------------- DSN: SageLine132 - Sage Line 100 DSN: SageLine50v10 - Sage Line 50 v10 DSN: Payroll32 - Microsoft Access Driver (*.mdb) DSN: DBISAMTEST - DBISAM 3 ODBC Driver DSN: HRUnityOnline - SQL Server DSN: PCS - SQL Server DSN: Bandvulc_PCS - SQL Server DSN: Bandvulc CCC - Sage Line 100