-
Improvement
-
Resolution: Unresolved
-
Minor
-
None
-
Future Dev
There are a bunch of use cases where you are working with arbitrary sql and you need access to the field names. Generally this is straight forward except in the case where no rows are returned.
For most of the DB api methods there isn't an obvious way to grab the metadata, perhaps we could introduce a new methods which grabs the metadata for the most recent call but that seems slightly ugly and we'd have to process and store a bunch of data that in most cases is never used.
So I'm thinking a good compromise is adding a new method just for recordsets which returns an ordered array of the field names (and maybe types too?), eg:
$rs = $DB->get_recordset_sql($sql);
$rs->get_fields(); <<<--------- THIS
foreach ($rs as $record) {
// ...
}
$rs->close();