Reputation: 7348
How to Get Field Name With Query in Zend Framework Test "Select * From Test1,Test2" how to get all field name in this query Zend Frame work cam do it?
Upvotes: 0
Views: 1904
Reputation: 22408
You could also issue $db->describeTable('Test1')
, etc. before or after the query which would provide you with all the meta information you need. This query is pretty expensive though, so make sure to cache the response.
Also, if you're using a model which extends Zend_Db_Table_Abstract
, then you should have all this information already. In this case, all you need to do is access the protected property $_metadata
.
HTH
Upvotes: 1
Reputation: 1836
Untested, but I believe the query is returned as an associative array (where the column name is the key), and so you can loop through the first record and pick up the column names, e.g.
$sql = 'Select * From Test1,Test2';
$result = $db->fetchAll($sql, 2);
foreach ($result[0] as $key => $value) {
echo $key;
...
}
Upvotes: 2