dbal icon indicating copy to clipboard operation
dbal copied to clipboard

DBAL-933: Get Statement Column Metadata

Open doctrinebot opened this issue 10 years ago • 3 comments

Jira issue originally created by user bburnichon:

It would be nice to have a utility method in \Doctrine\Dbal\Driver\ResultStatement to properly retrieve the result column names.

Currently, we have to rely on somthing like $columnNames = array_keys($statement->fetch(\PDO::FETCH_ASSOC));

Problem: It does not work with empty result-sets, and more checks should be performed to handle these.

With PDO, http://www.php.net/manual/en/pdostatement.getcolumnmeta.php could be used to properly retrieve names.

For Sqlite3 it is easy, http://www.php.net/manual/en/sqlite3result.columnname.php

For Mysql, http://www.php.net/manual/en/mysqli-result.fetch-fields.php would do the trick

doctrinebot avatar Jul 05 '14 11:07 doctrinebot

We cannot change this in 2.x as this would require an interface change. Scheduling this to be discussed for 3.0.

deeky666 avatar Jan 10 '16 20:01 deeky666

Isn't adding a new public method to the ResultStatement object a backwards compatible change? Why can't this be done in 2.x? The method is part of the PDOStatement API, which the ResultStatement API otherwise appears to mimic.

derekrprice avatar Dec 22 '17 15:12 derekrprice

Isn't adding a new public method to the ResultStatement object a backwards compatible change?

It is not. ResultStatement is an interface, any new methods introduced in interfaces are subject to BC breaks.

Majkl578 avatar Dec 22 '17 15:12 Majkl578

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

github-actions[bot] avatar Oct 04 '22 00:10 github-actions[bot]