- 4 years ago 199
SQL Question

Zend Mysql get ENUM values

I use

Zend Framework
in my application. And I want to know how to get values from ENUM field in
For example: i have
field (
('delete_admin', 'edit_admin')). How to get array('delete_admin', 'edit_admin') in he best way?
Thank you in advance.

Answer Source

This is how i did it:

in your model put this

function getInfoTabella()
        $data = $this->info(self::METADATA);
        return $data;

then use this:

$model = new $model_name();
        $description = $model->getInfoTabella();
        $enum = $description[$FIELD_NAME]['DATA_TYPE'];

        $inizia_enum = strpos($enum, "'");
        $finisce_enum = strrpos($enum, "'");
        if ($inizia_enum === false || $finisce_enum  === false)
            throw new Exception('errore enum database');

        $finisce_enum -= $inizia_enum ;

        $enum = substr($enum, $inizia_enum, $finisce_enum+1);
        str_replace("'", '', $enum);
        $enum = explode("," , $enum);
return $enum;
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download