Answers for "virtual fields cakephp"

PHP
1

virtual fields cakphp

// ------------------- 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 . '\'',
            )
        ),
    ),
));
Posted by: Guest on October-02-2020

Browse Popular Code Answers by Language