Enum Values in CakePHP

Reading time ~1 minute

MySQL is one of many DBS's. Because of this CakePHP doesn't support Enums. So what do you do?

You have to support it on your own, FORTUNATELY it's not too tough. First thing lets grab our enum values and punch them into an array.

<?
$myValues = $this->ModelName->getColumnType('enum_values');
preg_match_all("/'(.*?)'/", $myValues, $enums);
Then lets use compact to push the array to our view!

<?
$enum = $enums[1];
$this->set(compact('enum'));
Then we simply build our array in our view!

<?
echo $this->Form->input('enum_values',array('type'=>'select','options'=>$enum));

Complete. Now you should have a dropdown menu of options pulled straight out of our enum column!

ENJOY!

Asyncio Basics Python 35

# Asyncio basics in pythonPython 3.5 brought with it asyncio. An event loop based paradigm previously available as a library but now it i...… Continue reading

Quick Laravel/Lumen install with Docker!

Published on March 02, 2016

PHP To Python

Published on February 24, 2016