How to get Column Name With Zend DB

前端 未结 5 1554
梦如初夏
梦如初夏 2021-02-14 00:54

How to get Column Name With Zend DB

相关标签:
5条回答
  • 2021-02-14 01:30

    You could use the describeTable method

    0 讨论(0)
  • 2021-02-14 01:33

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

    $cols = $table->info(Zend_Db_Table_Abstract::COLS); 
    
    0 讨论(0)
  • 2021-02-14 01:33

    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

    0 讨论(0)
  • 2021-02-14 01:40

    I like this way:

    $table->info('cols');
    
    0 讨论(0)
  • 2021-02-14 01:50
    $metadata = $db->describeTable($tableName);
    $columnNames = array_keys($metadata);
    

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

    0 讨论(0)
提交回复
热议问题