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];
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!


Quick Laravel/Lumen install with Docker!

The default installer that comes with Laravel is great, but unfortunately that means you have to install dependencies of PHP and Laravel/...… Continue reading

PHP To Python

Published on February 24, 2016

Aftertouch in Logic Pro X and 2015 Macbook Pro

Published on February 24, 2016