join cakephp code example

Example 1: override belongto parent appmodel cakephp

// -------------------------------------------------------------
// ------------ Override belongto parent appmodel --------------
// -------------------------------------------------------------
public function __construct($id = false, $table = null, $ds = null) {
    $parent = get_parent_class($this);
    $this->_mergeVars(array('belongsTo'), $parent);	// override belongto parent appmodel

    parent::__construct($id, $table, $ds);
}

Example 2: join cakphp

'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 . '\'',
            )
        ),
    ),

Tags:

Php Example