Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get Column Name With Zend DB

How to get Column Name With Zend DB

like image 451
monkey_boys Avatar asked Apr 02 '09 08:04

monkey_boys


3 Answers

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

$cols = $table->info(Zend_Db_Table_Abstract::COLS); 
like image 169
corné Avatar answered Nov 02 '22 14:11

corné


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

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

like image 40
vartec Avatar answered Nov 02 '22 15:11

vartec


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

like image 2
Paamand Avatar answered Nov 02 '22 15:11

Paamand