now I understand, you want associated user animal info for all
specified Userpages...
so as I suggested before, do the find on Userpage model...
but use contain to provide the associated stuff:
$pages = $this-Userpage-find('all',array(
'conditions'=array(
'or'=array(
Yay! The query works! :)
Thank you! I really appreciate your patience. :)
Thanks for your time and knowledge!
~Sarah
On Aug 30, 11:07 pm, delocalizer conrad.leon...@hotmail.com wrote:
now I understand, you want associated user animal info for all
specified Userpages...
so as I
Ah I hadn't realised you just wanted Userpages - in which case why not
call find on Userpage?
If you're in Users controller:
$pages = $this-User-Userpage-find('all',array(
'conditions'=array(
'or'=array(
'approved'=1,
'and'=array(
I'm performing this in the Userpages controller. I was calling find
on Users because I need information on the user's animal.
User hasMany Userpages
User belongsTo Animal
The foreign keys are set up appropriately.
I need to get a list of all userpages in which: (Userpages.approved =
1) OR
ok... but I'm still not sure exactly what your intent is. When you say
you need information on THE user's animal - do you mean there is a
particular user that you are trying to get information on, like the
current requesting user? $id is a unique value in your method (ie. not
a loop iterator or
I would like the results from the query to include all userpages that
either have an approved value of 1 or belong to the current user
(whose id is stored in the $id var) and have an approved value of -1.
Basically I want a list of all userpages that are approved for public
viewing or that are
Hi Sarah,
If you have a reasonably complicated find query with associated models
and conditions, the core 'Containable' behaviour is very handy:
http://book.cakephp.org/view/474/Containable
so in your AppModel put this (and all your models will have access to
the behaviour):
var $actsAs =
Wow, this was very cool. Thank you for the advice.
I realized I had forgotten a condition. So this is where I am now:
$array = $this-User-find('all', array(
'fields'=array('id', 'animal_id'),
'order'=array('User.id'='asc'),
$conditions = array('or' = array(
'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:
Looks like you very nearly had it. Just got your find syntax slightly
wrong, try:
$array = $this-User-find('all', array(
'fields'=array('id, 'Userpage.id', 'User.animal_id',
'Animal.frontfilename'),
'conditions'=$conditions,
'order'=$order
);
Then go have a look at the cookbook and study
I fixed my syntax,
$conditions = array('or' = array( 'Userpage.approved' = 1, 'User.id'
= $id) );
$order = array('User.id ASC', 'Userpage.id DESC');
$array = $this-User-find('all', array('fields'=array('id',
'Userpage.id', 'User.animal_id', 'Animal.frontfilename'),
'conditions'=$conditions,
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
Ah, that worked. :)
Thank you!
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
The only problem I am having with this is that userpages are then
received like this:
[Userpage] = Array
(
[0] = Array
(
[id] = 2
[filename] = helloworld.html
[type] = text/html
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);
?
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
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
17 matches
Mail list logo