I am new in cakephp3
. I am trying to execute below query but its showing me error.
$lifeinsurances = TableRegistry::get('LifeInsurances')->find("all");
$life_insurances = $lifeinsurances->find()
->join([
'table' => 'institutions',
'alias' => 'institutions',
'type' => 'LEFT',
'conditions' => 'institutions.id = LifeInsurances.institute_id',
]);
I have fixed previous query. Now I am getting only one table data.
EDIT
Now I created association using cake bake. But a new error showing this time. Below is my code.
public function index() {
$this->paginate = [
'contain' => ['Institutions']
];
$lifeInsurances = $this->paginate($this->LifeInsurances);
$this->set(compact('lifeInsurances'));
$this->set('_serialize', ['lifeInsurances']);
}
Internal server error
if I remove
$this->paginate = [
'contain' => ['Institutions']
];
$lifeInsurances = $this->paginate($this->LifeInsurances);
error stop showing