How to get Column Name With Zend DB

好久不见. 提交于 2019-12-09 09:01:56

问题


How to get Column Name With Zend DB


回答1:


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

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



回答2:


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

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




回答3:


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




回答4:


You could use the describeTable method




回答5:


I like this way:

$table->info('cols');


来源:https://stackoverflow.com/questions/708782/how-to-get-column-name-with-zend-db

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!