virtual fields cakphp
snippet in php

virtual fields cakphp

user9709


// ------------------- CONCAT USE virtualFields
$this->virtualFields['myField'] = "CONCAT(language.name, ' (', language.description,  ')' )";	// using this for use concat
		
return $this->find('list', array(
    'fields' => array(
        'ImageType.id', 
        'myField',
    ),
    'conditions' => array(
        'ImageType.slug LIKE' => $slug,
    ),
    'joins' => array(
        array(
            'table' => Environment::read('table_prefix') . 'image_type_languages', 
            'alias' => 'language',
            'type' => 'INNER',
            'conditions'=> array(
                'ImageType.id = language.image_type_id',
                'language.alias = \'' . $language . '\'',
            )
        ),
    ),
));