Feature Request
| Q |
A |
| New Feature |
yes |
| RFC |
no |
Summary
Easy things to implement:
Result::getColumnCount(): int
Result::getColumnName(int $index): string
Trickier to abstract: Result::getColumnType(int $index) as we would have to define an abstraction for the column type. So not sure this should be part of this API for now.
Looking quickly, here is what I found for the drivers we have in core
- ext-sqlite3 has
SQLite3Result::numColumns, SQLite3Result::columnName and SQLite3Result::columnType (returning an integer corresponding to some constants)
- PDO has
PDOStatement::columnCount and PDOStatement::getColumnMeta (returning a shape with many keys and potentially not implemented by custom PDO drivers, but implemented by all core PDO drivers)
- ext-pgsql has
pg_num_fields, pg_field_name and pg_field_type
- ext-mysqli has
mysqli_result::$field_count to the field count and mysqli_result::fetch_field_direct to get info about the field
- ext-ibm-db2 has
db2_num_fields, db2_field_name and db2_field_type (and a few other db2_field_* functions)
- ext-oci8 has
oci_num_fields, oci_field_name and oci_field_type
- ext-sqlsrv has
sqlsrv_num_fields and sqlsrv_field_metadata (which gives the metadata for all fields as a list instead of taking an index as argument like for other extensions)
Feature Request
Summary
Easy things to implement:
Result::getColumnCount(): intResult::getColumnName(int $index): stringTrickier to abstract:
Result::getColumnType(int $index)as we would have to define an abstraction for the column type. So not sure this should be part of this API for now.Looking quickly, here is what I found for the drivers we have in core
SQLite3Result::numColumns,SQLite3Result::columnNameandSQLite3Result::columnType(returning an integer corresponding to some constants)PDOStatement::columnCountandPDOStatement::getColumnMeta(returning a shape with many keys and potentially not implemented by custom PDO drivers, but implemented by all core PDO drivers)pg_num_fields,pg_field_nameandpg_field_typemysqli_result::$field_countto the field count andmysqli_result::fetch_field_directto get info about the fielddb2_num_fields,db2_field_nameanddb2_field_type(and a few otherdb2_field_*functions)oci_num_fields,oci_field_nameandoci_field_typesqlsrv_num_fieldsandsqlsrv_field_metadata(which gives the metadata for all fields as a list instead of taking an index as argument like for other extensions)