Hi Ralf,

I extended Zend_Db_Table and added this little method. But I am afraid,
this might only be working for MySQL.

    public function getOptions($column)
    {
        // build select to read column definition for selected column
        $sql  = " SHOW COLUMNS ";
        $sql .= "         FROM " . $this->_name;
        $sql .= "         LIKE '" . $column . "'";

        $result = $this->getAdapter()->fetchRow($sql);

        // user regular expression to get option list from result
        preg_match("=\((.*)\)=is", $result["Type"], $options);

        // replace single quotes
        $options = str_replace("'", "", $options[1]);

        // explode string into an array
        $options = explode(",", $options);

        return $options;
    }

HTH.

Best Regards,

Ralf


Reply via email to