I've found an issue while working with php ODBC functions. odbc_fetch_array and odbc_fetch_object fail when query has a join with a table that has the same column name, even when that certain field is excluded from the field selection (With SQL SERVER):
THIS ONLY HAPPENS WHEN USING SQL_CUR_USE_ODBC
for example
$con = odbc_connect("Driver={SQL Server Native Client 11.0};Server=$serverName;Database=$db;", 'user', 'pass',SQL_CUR_USE_ODBC);
$query="SELECT table1.field1, table1.field2 from table1 JOIN table2 ON table1.field1=table2.field1";
$result = odbc_exec($con,$query);
$a=odbc_fetch_array($result);
the code above generates a warning:
Warning: odbc_fetch_array() [function.odbc-fetch-array]: SQL error: [Microsoft][SQL Server Native Client 10.0][SQL Server]the column name '' is ambiguous., SQL state 37000 in SQLGetData
The error would be okay if i had selected field1 without specifying from which table, but even when it is explicit it doesn't work. the only "workaround" i've found so far is to remove the field from the selected fields or changinf the field name from the second table
I tried with: both SQL Server Native Client 10.0 and SQL Server Native Client 11.0 SQL server 2008 Php 5.3.2 over Windows
PD: If someone has any aideas without using sqlsrv or mssqL extension it will be great