views:

1439

answers:

3

How to get Column Name With Zend DB

A: 

You could use the describeTable method

Andrei Serdeliuc
+1  A: 
$metadata = $db->describeTable($tableName);
$columnNames = array_keys($metadata);

http://framework.zend.com/manual/en/zend.db.html#zend.db.adapter.list-describe

vartec
That's not really 100% correct as $metadata is an associative array ('column_name' => array()) of associative arrays (one for each column of the table).
Stefan Gehrig
+2  A: 

This is the correct answer, the older answers are wrong or outdated:

$cols = $table->info(Zend_Db_Table_Abstract::COLS);
corné
rewrote your intro-text since SO doesn't know 'bumping' and questions/answers are not considered old. in fact SO is a wiki and updating it is one of the best things you can do! +1
tharkun