Saturday, October 29, 2011

Re: find with fields and conditions

> 'Company.Departement_dactivite_limitrophes'
do you really have your table fields starting with a capital letter?
Not sure if this is the problem, would also try restricting what
associations are being used by using containable or recursive = -1

HTH, Paul

On Oct 29, 1:38 am, Ricardo <mastermind...@gmail.com> wrote:
> Hello All,
>
> I'm getting a weird error here, see I have the following find
> statement
>
> $cond1 = $this->Company->find('all',
>                                                      'conditions' =>
> array('Company.Departement_dactivite_limitrophes' => $department),
>                                                      'fields' => $fields
>                                                  )
>                                                   );
>
> $fields is an array with the field names, and $department comes from
> user info
>
> when it runs I get the following error:
>
> Warning (512): SQL Error: 1054: Field 'Company' unknown in WHERE
> clause [CORE / cake / libs / model / datasources / dbo_source.php,
> line 684]
>
> and the related generated query is:
>
> Query: SELECT COUNT(*) AS `count` FROM `companies` AS `Company`
> WHERE Company IN ([loads of fields]) AND Company IN ([loads of correct
> values]) AND Company IN... and so on for the rest of the search
> resutls
>
> Query: SELECT `Company`.`id`, `Company`.`nom_raison_sociale`,
> `Company`.`label`, `Company`.`type_de_prestataire`,
> `Company`.`code_postale`, `Company`.`email` FROM `companies` AS
> `Company`   WHERE Company IN ([loads of values]) AND Company IN ...
> and so on for the rest of the search resutls
>
> according to the stack trace, this error comes from the paginate
> function, where I send data like this:
>
> $data_table = $this->paginate($cond1);

--
Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org
Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions.


To unsubscribe from this group, send email to
cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php

No comments: