Get column names from a Zend_Db_Table object

If you need to get access to the column names of a Zend_Db_Table object (filtering a list of column names so that you discard any that don’t match up, for example) then as found on StackOverflow you can do the following:

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

Which of course works from within the object itself, so you could write a method such as:

public function getCols() {
        return $this->info(Zend_Db_Table_Abstract::COLS);
}

However unlike the documentation says, this does not appear to work…

//return $this->_cols;

26 comments