Question

How to get Column Name With Zend DB

Was it helpful?

Solution

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

$cols = $table->info(Zend_Db_Table_Abstract::COLS); 

OTHER TIPS

$metadata = $db->describeTable($tableName);
$columnNames = array_keys($metadata);

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

Previous answer applies only to version < 2.
For current version of ZF (2.2) use:

$table = new Zend\Db\TableGateway\TableGateway('table', $Dbadapter, new Zend\Db\TableGateway\Feature\MetadataFeature());
$columns = $table->getColumns();

http://framework.zend.com/manual/2.2/en/modules/zend.db.table-gateway.html#tablegateway-features http://framework.zend.com/manual/2.2/en/modules/zend.db.metadata.html

You could use the describeTable method

I like this way:

$table->info('cols');
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top