Contain HABTM

2009-08-05 Thread Dave Maharaj :: WidePixels.com
Is it possable to use contain to find HABTM data?
 
I have 
 
Posts
Amenities
Posts_Amenities
 
So I need a simple function to pull some user info and thier HABTM Amenities
 
Dave

--~--~-~--~~~---~--~~
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+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: Contain HABTM

2009-08-05 Thread Carlos Suarez Fontalvo

Excuse me, but pliz add some details, we are not sorcerers.

On 5 ago, 14:58, Dave Maharaj :: WidePixels.com
d...@widepixels.com wrote:
 Is it possable to use contain to find HABTM data?

 I have

 Posts
 Amenities
 Posts_Amenities

 So I need a simple function to pull some user info and thier HABTM Amenities

 Dave
--~--~-~--~~~---~--~~
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+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: Contain HABTM

2009-08-05 Thread pomares

What are the fields you want in your array?
--~--~-~--~~~---~--~~
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+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



RE: Contain HABTM

2009-08-05 Thread Dave Maharaj :: WidePixels.com

Thanks,

I figured it out.

function __getAmenities ($id)
{
 $params = array('conditions' = array('User.id' = $id),
 'fields' =
array('User.id'),
'contain' = array('Amenity'
= array('UsersAmenities')));
 
 $amenities = $this-find('first', $params);
 return $amenities;
} 

-Original Message-
From: pomares [mailto:k...@gordonpomarescentre.com] 
Sent: August-05-09 9:16 PM
To: CakePHP
Subject: Re: Contain HABTM


What are the fields you want in your array?


--~--~-~--~~~---~--~~
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+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: contain HABTM

2009-04-25 Thread rich...@home

You don't need contain, unless you want the post data too:

$this-Post-Subject-find(all, array(
  conditions=array(
Subject.post_id=$post_id
  )
);

If you do need the post data, brian's solution should work just fine.

On Apr 25, 5:21 am, brian bally.z...@gmail.com wrote:
 This doesn't work?

 $this-find(
         'first',
         array(
                 'conditions' = array(
                         'Post.id' = $post_id
                 ),
                 'contain' = array(
                         'Subject'
                 )
         )
 );

 On Fri, Apr 24, 2009 at 11:30 PM, Dave Maharaj :: WidePixels.com

 d...@widepixels.com wrote:
  Can someone help me with a contain using a HABTM relationship.
  POSTS HABTM SUBJECTS
  SUBJECTS
  POSTS_SUBJECTS

  I have Post HABTM SUBECTS

  I just want to print out the array of SUBJECTS that the POST has.

  I managed to get the rest of the contain for the other hasmany tables...just
  cant get the HABTM

  Thanks

  Dave
--~--~-~--~~~---~--~~
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+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: contain HABTM

2009-04-25 Thread brian

Yeah, I should have been more clear. I'm assuming that the Post info
is being fetched, also.

On Sat, Apr 25, 2009 at 3:54 AM, rich...@home richardath...@gmail.com wrote:

 You don't need contain, unless you want the post data too:

 $this-Post-Subject-find(all, array(
  conditions=array(
    Subject.post_id=$post_id
  )
 );

 If you do need the post data, brian's solution should work just fine.

 On Apr 25, 5:21 am, brian bally.z...@gmail.com wrote:
 This doesn't work?

 $this-find(
         'first',
         array(
                 'conditions' = array(
                         'Post.id' = $post_id
                 ),
                 'contain' = array(
                         'Subject'
                 )
         )
 );

 On Fri, Apr 24, 2009 at 11:30 PM, Dave Maharaj :: WidePixels.com

 d...@widepixels.com wrote:
  Can someone help me with a contain using a HABTM relationship.
  POSTS HABTM SUBJECTS
  SUBJECTS
  POSTS_SUBJECTS

  I have Post HABTM SUBECTS

  I just want to print out the array of SUBJECTS that the POST has.

  I managed to get the rest of the contain for the other hasmany 
  tables...just
  cant get the HABTM

  Thanks

  Dave
 


--~--~-~--~~~---~--~~
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+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



RE: contain HABTM

2009-04-25 Thread Dave Maharaj :: WidePixels.com

'contain' = array(
'Subject' = array('fields' = array('Subject.name')),

 The array looks like this 

[Subject] = Array
(
[0] = Array
(
[name] = Political Science
[PostsSubject] = Array
(
[id] = 1
[post_id] = 1
[subject_id] = 1
)

)

What I do not need is anything in the PostsSubjects array and want to remove
that. 

-Original Message-
From: Dave Maharaj :: WidePixels.com [mailto:d...@widepixels.com] 
Sent: April-25-09 2:14 PM
To: cake-php@googlegroups.com
Subject: RE: contain HABTM


Sorry for the confusion.

The POST has about 10 other tables its related to but I do not want to pull
all that data associated with it. So I am trying to contain the tables I
needed and the fields.



-Original Message-
From: brian [mailto:bally.z...@gmail.com]
Sent: April-25-09 12:54 PM
To: cake-php@googlegroups.com
Subject: Re: contain HABTM


Yeah, I should have been more clear. I'm assuming that the Post info is
being fetched, also.

On Sat, Apr 25, 2009 at 3:54 AM, rich...@home richardath...@gmail.com
wrote:

 You don't need contain, unless you want the post data too:

 $this-Post-Subject-find(all, array(
  conditions=array(
    Subject.post_id=$post_id
  )
 );

 If you do need the post data, brian's solution should work just fine.

 On Apr 25, 5:21 am, brian bally.z...@gmail.com wrote:
 This doesn't work?

 $this-find(
         'first',
         array(
                 'conditions' = array(
                         'Post.id' = $post_id
                 ),
                 'contain' = array(
                         'Subject'
                 )
         )
 );

 On Fri, Apr 24, 2009 at 11:30 PM, Dave Maharaj :: WidePixels.com

 d...@widepixels.com wrote:
  Can someone help me with a contain using a HABTM relationship.
  POSTS HABTM SUBJECTS
  SUBJECTS
  POSTS_SUBJECTS

  I have Post HABTM SUBECTS

  I just want to print out the array of SUBJECTS that the POST has.

  I managed to get the rest of the contain for the other hasmany 
  tables...just cant get the HABTM

  Thanks

  Dave
 






--~--~-~--~~~---~--~~
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+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



RE: contain HABTM

2009-04-25 Thread Dave Maharaj :: WidePixels.com

Sorry for the confusion.

The POST has about 10 other tables its related to but I do not want to pull
all that data associated with it. So I am trying to contain the tables I
needed and the fields.



-Original Message-
From: brian [mailto:bally.z...@gmail.com] 
Sent: April-25-09 12:54 PM
To: cake-php@googlegroups.com
Subject: Re: contain HABTM


Yeah, I should have been more clear. I'm assuming that the Post info is
being fetched, also.

On Sat, Apr 25, 2009 at 3:54 AM, rich...@home richardath...@gmail.com
wrote:

 You don't need contain, unless you want the post data too:

 $this-Post-Subject-find(all, array(
  conditions=array(
    Subject.post_id=$post_id
  )
 );

 If you do need the post data, brian's solution should work just fine.

 On Apr 25, 5:21 am, brian bally.z...@gmail.com wrote:
 This doesn't work?

 $this-find(
         'first',
         array(
                 'conditions' = array(
                         'Post.id' = $post_id
                 ),
                 'contain' = array(
                         'Subject'
                 )
         )
 );

 On Fri, Apr 24, 2009 at 11:30 PM, Dave Maharaj :: WidePixels.com

 d...@widepixels.com wrote:
  Can someone help me with a contain using a HABTM relationship.
  POSTS HABTM SUBJECTS
  SUBJECTS
  POSTS_SUBJECTS

  I have Post HABTM SUBECTS

  I just want to print out the array of SUBJECTS that the POST has.

  I managed to get the rest of the contain for the other hasmany 
  tables...just cant get the HABTM

  Thanks

  Dave
 




--~--~-~--~~~---~--~~
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+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



contain HABTM

2009-04-24 Thread Dave Maharaj :: WidePixels.com
Can someone help me with a contain using a HABTM relationship.
POSTS HABTM SUBJECTS
SUBJECTS 
POSTS_SUBJECTS
 
I have Post HABTM SUBECTS 
 
I just want to print out the array of SUBJECTS that the POST has.
 
I managed to get the rest of the contain for the other hasmany tables...just
cant get the HABTM
 
Thanks
 
Dave 

--~--~-~--~~~---~--~~
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+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: contain HABTM

2009-04-24 Thread brian

This doesn't work?

$this-find(
'first',
array(
'conditions' = array(
'Post.id' = $post_id
),
'contain' = array(
'Subject'
)
)
);

On Fri, Apr 24, 2009 at 11:30 PM, Dave Maharaj :: WidePixels.com
d...@widepixels.com wrote:
 Can someone help me with a contain using a HABTM relationship.
 POSTS HABTM SUBJECTS
 SUBJECTS
 POSTS_SUBJECTS

 I have Post HABTM SUBECTS

 I just want to print out the array of SUBJECTS that the POST has.

 I managed to get the rest of the contain for the other hasmany tables...just
 cant get the HABTM

 Thanks

 Dave
 


--~--~-~--~~~---~--~~
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+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---