I use Zend Framework
in my application. And I want to know how to get values from ENUM field in MySQL
table.
For example: i have permissions
field (ENUM
('delete_admin', 'edit_admin')). How to get array('delete_admin', 'edit_admin') in he best way?
Thank you in advance.
相关问题
- Views base64 encoded blob in HTML with PHP
- Laravel Option Select - Default Issue
- PHP Recursively File Folder Scan Sorted by Modific
- Can php detect if javascript is on or not?
- Using similar_text and strpos together
Add this in your Zend_Table class:
A method for your application model mapper. Assuming your_field_name is the name of the database column that you need to list the ENUM values of.
The method returns an array with the ENUM values of your_field_name column.
Add a method to your Zend_Db_Table_Abstract extended class.
This is how you can get an explode-ready string from MySQL:
You just need to do a
explode(',' $result)
on it to get an array with your enum-values.Remember that you need read-access to information_schema-database to do this.
This is how i did it:
in your model put this
then use this:
I did it in next way: