Bug #75534 [NEW]: Column aliases not working with FreeTDS
From: chris at ocproducts dot com
Operating system:
PHP version: 7.1.11
Package: ODBC related
Bug Type: Bug
Bug description:Column aliases not working with FreeTDS
Description:
------------
I am on a Mac using recent versions of FreeTDS (1.00.70, homebrew) and
unixODBC (2.3.4, homebrew), connecting to SQL Server Express 2017 on
Windows 10.
Column aliases (e.g. SELECT foo AS bar FROM something) are not
respected. odbc_field_name will return 'foo', not 'bar'.
This is a known issue, but as far as I can see was never reporting
directly to PHP as a bug.
Discussed on FreeTDS mailing list:
https://lists.ibiblio.org/pipermail/freetds/2010q2/025720.html
https://lists.ibiblio.org/pipermail/freetds/2012q1/027752.html
It is FreeTDS version specific, as at some point they improved their
ODBC support to return original table field names rather than only
aliases, with PHP now failing on assuming nothing will do that
correctly.
Many asking questions across the web, and using kludgy workarounds like
forced casts or noop expressions or downgrading the TDS protocol
version:
https://stackoverflow.com/questions/10597898/php-unixodbc-freetds-select-field-as-name-does-not-work
https://github.com/ADOdb/ADOdb/issues/141
http://www.devnetwork.net/viewtopic.php?f=2&t=128778
I was able to resolve via a trivial patch, which is attached.
I am by no means an expert on ODBC. I can't confirm all ODBC
implementations will correctly SQL_DESC_NAME, only that using it
corrects my issue.
--
Edit bug report at https://bugs.php.net/bug.php?id=75534&edit=1
--
Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=75534&r=trysnapshot54
Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=75534&r=trysnapshot55
Try a snapshot (trunk): https://bugs.php.net/fix.php?id=75534&r=trysnapshottrunk
Fixed in SVN: https://bugs.php.net/fix.php?id=75534&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=75534&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=75534&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=75534&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=75534&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=75534&r=support
Expected behavior: https://bugs.php.net/fix.php?id=75534&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=75534&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=75534&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=75534&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=75534&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=75534&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=75534&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=75534&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=75534&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=75534&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=75534&r=mysqlcfg
Thread (3 messages)
- chris at ocproducts dot com