Req #81550 [Fbk]: getColumnMeta returns aliases of tables and fields instead of the base names.
| From: | requinix@php.net | Date: | Mon, 25 Oct 2021 15:31:10 +0000 |
| Subject: | Req #81550 [Fbk]: getColumnMeta returns aliases of tables and fields instead of the base names. | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-237362@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=81550&edit=1
ID: 81550
Updated by: requinix@php.net
Reported by: daniel dot garcia dot fidalgo at gmail dot com
Summary: getColumnMeta returns aliases of tables and fields
instead of the base names.
Status: Feedback
Type: Feature/Change Request
Package: PDO MySQL
Operating System: CentOS 7
PHP Version: 7.3.31
Assigned To: cmb
Block user comment: N
Private report: N
New Comment:
See MYSQL_FIELD in https://dev.mysql.com/doc/c-api/8.0/en/c-api-data-structures.html
Looking at this from the feature request view, what about adding the original table (org_table) and
column names (org_name) to the array?
Not sure how it applies to other drivers, like pdo_pgsql/PostgreSQL seems to do identifiers instead
of names, but the original names could be one more of PDO's "...if supported by the
driver" features.
At the least there does seem to be some precedent for driver-specific values in the returned array:
pdo_pgsql adds a "pgsql:table_oid" to the array. So pdo_mysql could potentially do
"mysql:org_name/org_table" if it had to.
Previous Comments:
------------------------------------------------------------------------
[2021-10-25 13:54:49] cmb@php.net
> The aliased names as set in the query are returned.
Right. And the documentation states[1]:
| The name of this column as returned by the database.
So where's the problem?
[1] <https://www.php.net/manual/en/pdostatement.getcolumnmeta.php#refsect1-pdostatement.getcolumnmeta-returnvalues>
------------------------------------------------------------------------
[2021-10-21 17:31:20] daniel dot garcia dot fidalgo at gmail dot com
Description:
------------
getColumnMeta() function returns aliases of tables and fields instead of the base names.
Test script:
---------------
Original query:
SELECT
FormuId AS FormuId__FormId__V,
Formdate AS Formdate__Date__v,
GROUP_CONCAT(FieldValue ORDER BY id_sysformdb) AS Contact__v
FROM
Sysformdb AS F
WHERE
(F.Fieldname = 'frm_fld_Name' OR
F.Fieldname = 'frm_fld_Lastname' OR
F.FieldName = 'frm_fld_E-mail')
GROUP BY
FormuId
ORDER BY
id_sysformdb
DESC LIMIT 50
getColumnMeta() returned data:
array(7) { ["native_type"]=> string(6) "STRING" ["pdo_type"]=>
int(2) ["flags"]=> array(0) { } ["table"]=> string(1) "F"
["name"]=> string(9) "FormId__V" ["len"]=> int(30)
["precision"]=> int(0) }
array(7) { ["native_type"]=> string(9) "TIMESTAMP"
["pdo_type"]=> int(2) ["flags"]=> array(0) { } ["table"]=>
string(1) "F" ["name"]=> string(7) "Date__v" ["len"]=>
int(19) ["precision"]=> int(0) }
array(7) { ["native_type"]=> string(4) "BLOB" ["pdo_type"]=>
int(2) ["flags"]=> array(1) { [0]=> string(4) "blob" }
["table"]=> string(0) "" ["name"]=> string(10)
"Contact__v" ["len"]=> int(50331645) ["precision"]=> int(0) }
Expected result:
----------------
The base name of tables and fields is expected as named in the db schema
Actual result:
--------------
The aliased names as set in the query are returned.
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=81550&edit=1