'Userpage.approved' => 1,
'User.id' => $id
)
);
$order = array('User.id ASC', 'Userpage.id DESC');
$array = $this->User->find($conditions, array('id, 'Userpage.id',
'User.animal_id', 'Animal.frontfilename'), $order);
I get the following errors:
Warning (512): SQL Error: 1054: Unknown column 'Userpage.id' in 'field
list' [CORE/cake/libs/model/datasources/dbo_source.php, line 525]
Query: SELECT `User`.`id`, `Userpage`.`id`, `User`.`animal_id`,
`Animal`.`frontfilename` FROM `users` AS `User` LEFT JOIN `animals` AS
`Animal` ON (`User`.`animal_id` = `Animal`.`id`) LEFT JOIN `groups` AS
`Group` ON (`User`.`group_id` = `Group`.`id`) WHERE
((`Userpage`.`approved` = 1) OR (`User`.`id` = 116)) ORDER BY
`User`.`id` ASC, `Userpage`.`id` DESC LIMIT 1
Warning (512): SQL Error: 1054: Unknown column 'Userpage.approved' in
'where clause' [CORE/cake/libs/model/datasources/dbo_source.php, line
525]
Query: SELECT `User`.`id`, `User`.`username`, `User`.`firstname`,
`User`.`lastname`, `User`.`email`, `User`.`created`,
`User`.`animal_id`, `User`.`password`, `User`.`group_id`,
`Animal`.`id`, `Animal`.`name`, `Animal`.`frontfilename`,
`Animal`.`sidefilename`, `Animal`.`facefilename`, `Animal`.`created`,
`Group`.`id`, `Group`.`name`, `Group`.`created`, `Group`.`modified`
FROM `users` AS `User` LEFT JOIN `animals` AS `Animal` ON
(`User`.`animal_id` = `Animal`.`id`) LEFT JOIN `groups` AS `Group` ON
(`User`.`group_id` = `Group`.`id`) WHERE ((`Userpage`.`approved` = 1)
OR (`User`.`id` = 116)) LIMIT 1
I use the Userpage information to choose which Userpages to add to the
array. What I'm trying to accomplish is to get all Userpages that
have an approved value of 1, or belong to the logged in user.
Thanks for your time and help!
~Sarah
On Aug 27, 7:10 pm, delocalizer <conrad.leon...@hotmail.com> wrote:
> Hi Sarah;
> I'm not sure what you are asking.
> User hasmany Userpages, so Userpage array will contain all the
> Userpages belonging to User.
> $example = $this->User->find('first');
> foreach($example['Userpage'] as $key=>$value){
> debug($value['id']);
>
> }
>
> On Aug 28, 9:18 am, Sarah <sarah.e.p.jo...@gmail.com> wrote:
>
> > To clarify, I get the error message:
> > Warning (512): SQL Error: 1054: Unknown column 'Userpage.id' in 'field
> > list' [CORE/cake/libs/model/datasources/dbo_source.php, line 525]
> > When I try to get select the Userpage.id field.
>
> > On Aug 27, 3:19 pm, delocalizer <conrad.leon...@hotmail.com> wrote:
>
> > > Hi Sarah;
> > > If your relationships are set up correctly and you have recursive >
> > > -1, the usual 'find' method on User model should be returning the
> > > parent 'Animal' anyway - what do you see if you put this in one of
> > > your user controller functions:
> > > $example = $this->User->find('first');
> > > debug($example);
> > > ?
>
> > > On Aug 28, 6:01 am, Sarah <sarah.e.p.jo...@gmail.com> wrote:
>
> > > > This is my setup:
>
> > > > A 'user' hasMany 'userpage's.
> > > > A 'user' belongsTo an 'animal'.
>
> > > > I would like to be able to display user information as well as some
> > > > information about the user's animal on a userpage view.
>
> > > > I perform a find query to get the userpage id, user_id, animal_id.
>
> > > > Is there a way to search for Animal information as well?
> > > > This won't work because of the last field, but this is conceptually
> > > > what I want:
>
> > > > 'fields'=>array('user_id', 'id', 'User.animal_id',
> > > > 'User.Animal.frontfilename')
>
> > > > Thanks in advance!
> > > > ~Sarah
--~--~---------~--~----~------------~-------~--~----~
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:
Post a Comment