View Single Post
  #1 (permalink)  
Old 07-07-2007, 08:46 AM
andrewtayloruk andrewtayloruk is offline
Junior Member
 
Join Date: Jun 2007
Posts: 6
Default Placement of generic functions / helpers for models

Hi,

I've got a number of models defined in my application. In each model I have the function:

PHP Code:
function generateOptionsFromMeta() {

    
$enumList = Array();

    foreach(
$this->_metadata AS $fieldName => $fieldAttributes) {
    
        if(
'enum' == substr($fieldAttributes['DATA_TYPE'],0,4)) {
        
            foreach(eval(
'return '.str_replace('enum''Array'$fieldAttributes['DATA_TYPE'].';')) AS $key => $value) {
            
                
$enumList[$fieldName][$value] = $value;
            }
        }
    }
    
    return(
$enumList);

Obviously this needs re-factoring, where can I place these types of functions that are usable on every model without modification?

Thanks

Andrew
Reply With Quote