On Tue, Oct 26, 2010 at 5:10 PM, rafadev <[email protected]> wrote: > Hello! > > I have Contracts model that hasMany ContractExportDate. > > If I just do: > > $this->Contract->recursive = 1; > $this->set('contracts', $this->paginate()); > > the $contracts variable contains the contract itself, along with > ContractExportDate: > > [0] => Array > ( > [Contract] => Array > ( > [id] => 2 > (.......) > [contractor_id] => 1 > [contract_type_id] => 3 > [status_id] => 202 > ), > [ContractApprovalDate] => Array > ( > [0] => Array > ( > [id] => 40 > [approval_date] => 2010-01-22 15:19:20 > (.......) > ) > > ) > > But if I specify it explicity on the $paginate array: > > var $paginate = array( > 'limit' => 20, > 'fields' => array( > 'id', > 'from_date', > 'to_date', > 'division_id', > 'contractor_id', > 'contract_type_id', > 'status_id', > 'Contractor.id', > 'Contractor.firstname', > 'Contractor.lastname', > 'Division.name', > 'ContractExportDate.export_date') > ); > > I get this error: > > Warning (512): SQL Error: 1054: Unknown column > 'ContractExportDate.export_date' in 'field list > > Any ideas?
You should study Model.php to see how it builds its queries. And consider using ContainableBehavior. What you're trying to do is similar to how 'contain' operates. Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
