Thursday, July 2, 2009

Re: BelongsTo Fields Error

Try the fields without the table qualifier: 'id,surname,name'

Rick

On Jul 1, 11:24 am, "marco.rizze...@gmail.com"
<marco.rizze...@gmail.com> wrote:
> Hi
> I have this model:
>
> class Document extends AppModel{
>
>         var $belongsTo = array(
>                 'Author'=>array(
>                         'className'  => 'User',
>                         'conditions' => '',
>                         'fields'         => 'Author.id,Author.surname,Author.name',
>                         'dependent'  => false,
>                         'order'      => '',
>                         'foreignKey' => 'author'
>                 )
>         );
>
> }
>
> Now in my controller if i do a
> .......
> $options=array(
>     'fields'=> array
> ('Document.id','Author.id','Author.username','Author.password')
> );
> $this->Document->find('all',$options);
>
> I get USERNAME and PASSWORD of the user that is the author of
> document.
> Sorry but this is an error or I mistake?
> I would that only setted fields (in this case
> 'Author.id,Author.surname,Author.name') must be present in belongsTo
> association?
> Marco
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
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?hl=en
-~----------~----~----~----~------~----~------~--~---

No comments: