Re: Help with User - Friend HABTM relationship

2010-05-21 Thread bradmaxs
Worked like a charm! Thanks again!

On May 20, 9:52 pm, bradmaxs  wrote:
> Thank you Calvin.  Working hard to figure all of this out and your
> suggestion was exactly what I was looking for.
>
> I will be working on this tomorrow and let you know how it works out.
>
> On May 20, 6:36 pm, calvin  wrote:
>
>
>
> > That's a PHP question, not a Cake question.
>
> > If you want to combine the arrays, then just combine them like you
> > would any other array.
>
> > If you have:
>
> > $friends = array('friend 1', 'friend 2', 'friend 3', ...);
> > $admirers = array('admirer 1', 'admirer 2', 'admirer 3', ...);
>
> > how would you combine them?
>
> > Well, the obvious solution is with array_merge():
> > $friendsAndAdmirers = array_merge($friends, $admirers);
>
> > If you want to filter out duplicates (i.e. if a person is both a
> > friend and an admirer), then use array_unique() on top of
> > array_merge().
>
> > I would suggest bookmarking--or, better yet, installing the Firefox
> > search tool for--the PHP Manual:http://us3.php.net/manual/en/index.php
>
> > On May 20, 11:31 am, bradmaxs  wrote:
>
> > > Anyone able to help me on this?
>
> > > On May 18, 4:55 pm, bradmaxs  wrote:
>
> > > > Hello All,
>
> > > > In response to the following post:
>
> > > >http://groups.google.com/group/cake-php/browse_thread/thread/c8ebc209...
>
> > > > I have come up with my users having friends and admirers, thank you
> > > > gentlemen for that.
>
> > > > I am getting the array for both of them in my dump.
>
> > > >     [friend] => Array
> > > >         (
> > > >             [0] => Array
> > > >                 (
> > > >                     [id] => 3
> > > >                     [username] => artist
>
> > > >                     [Friend] => Array
> > > >                         (
> > > >                             [id] => 1
> > > >                             [user_id] => 4
> > > >                             [friend_id] => 3
> > > >                             [approved] => 1
> > > >                         )
>
> > > >                 )
>
> > > >             [1] => Array
> > > >                 (
> > > >                     [id] => 5
> > > >                     [username] => testing
>
> > > >                     [Friend] => Array
> > > >                         (
> > > >                             [id] => 2
> > > >                             [user_id] => 4
> > > >                             [friend_id] => 5
> > > >                             [approved] => 1
> > > >                         )
>
> > > >                 )
>
> > > >         )
>
> > > >     [admirer] => Array
> > > >         (
> > > >             [0] => Array
> > > >                 (
> > > >                     [id] => 5
> > > >                     [username] => testing
>
> > > >                     [Friend] => Array
> > > >                         (
> > > >                             [id] => 3
> > > >                             [user_id] => 5
> > > >                             [friend_id] => 4
> > > >                             [approved] => 0
>
> > > > My question, and I think it is simple but I am still a newbie for the
> > > > most part -
>
> > > > How do I combine that data in the view to have both friends and
> > > > admirers as part of the same foreach statement?
>
> > > > Is that possible?  I have looked at Set::merge and tried that from the
> > > > controller.  Looked at custom query methods but the data is already
> > > > there in an array so I am a little stuck.
>
> > > > Here is what is in my view for the friends array and it is working
> > > > fine.  Just don't know how to get the admirer as part of it.
>
> > > > 
> > > > 
> > > > 
> > > > Html->link(__('View', true), array('controller' =>
> > > > 'friends', 'action' => 'view', $friend['id'])); ?>
> > > > Html->link(__('Delete', true), array('controller' =>
> > > > 'friends', 'action' => 'delete', $friend['id']), null, sprintf(__('Are
> > > > you sure you want to delete # %s?', true), $friend['id'])); ?>
> > > > 
>
> > > > Thanks for any help!
>
> > > > Brad
>
> > > > Check out the new CakePHP Questions 
> > > > sitehttp://cakeqs.organdhelpotherswith their CakePHP related questions.
>
> > > > 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 athttp://groups.google.com/group/cake-php?hl=en
>
> > > Check out the new CakePHP Questions sitehttp://cakeqs.organdhelpothers 
> > > with their CakePHP related questions.
>
> > > 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 
> > > athttp://groups.google

Re: Help with User - Friend HABTM relationship

2010-05-20 Thread bradmaxs
Thank you Calvin.  Working hard to figure all of this out and your
suggestion was exactly what I was looking for.

I will be working on this tomorrow and let you know how it works out.

On May 20, 6:36 pm, calvin  wrote:
> That's a PHP question, not a Cake question.
>
> If you want to combine the arrays, then just combine them like you
> would any other array.
>
> If you have:
>
> $friends = array('friend 1', 'friend 2', 'friend 3', ...);
> $admirers = array('admirer 1', 'admirer 2', 'admirer 3', ...);
>
> how would you combine them?
>
> Well, the obvious solution is with array_merge():
> $friendsAndAdmirers = array_merge($friends, $admirers);
>
> If you want to filter out duplicates (i.e. if a person is both a
> friend and an admirer), then use array_unique() on top of
> array_merge().
>
> I would suggest bookmarking--or, better yet, installing the Firefox
> search tool for--the PHP Manual:http://us3.php.net/manual/en/index.php
>
> On May 20, 11:31 am, bradmaxs  wrote:
>
>
>
> > Anyone able to help me on this?
>
> > On May 18, 4:55 pm, bradmaxs  wrote:
>
> > > Hello All,
>
> > > In response to the following post:
>
> > >http://groups.google.com/group/cake-php/browse_thread/thread/c8ebc209...
>
> > > I have come up with my users having friends and admirers, thank you
> > > gentlemen for that.
>
> > > I am getting the array for both of them in my dump.
>
> > >     [friend] => Array
> > >         (
> > >             [0] => Array
> > >                 (
> > >                     [id] => 3
> > >                     [username] => artist
>
> > >                     [Friend] => Array
> > >                         (
> > >                             [id] => 1
> > >                             [user_id] => 4
> > >                             [friend_id] => 3
> > >                             [approved] => 1
> > >                         )
>
> > >                 )
>
> > >             [1] => Array
> > >                 (
> > >                     [id] => 5
> > >                     [username] => testing
>
> > >                     [Friend] => Array
> > >                         (
> > >                             [id] => 2
> > >                             [user_id] => 4
> > >                             [friend_id] => 5
> > >                             [approved] => 1
> > >                         )
>
> > >                 )
>
> > >         )
>
> > >     [admirer] => Array
> > >         (
> > >             [0] => Array
> > >                 (
> > >                     [id] => 5
> > >                     [username] => testing
>
> > >                     [Friend] => Array
> > >                         (
> > >                             [id] => 3
> > >                             [user_id] => 5
> > >                             [friend_id] => 4
> > >                             [approved] => 0
>
> > > My question, and I think it is simple but I am still a newbie for the
> > > most part -
>
> > > How do I combine that data in the view to have both friends and
> > > admirers as part of the same foreach statement?
>
> > > Is that possible?  I have looked at Set::merge and tried that from the
> > > controller.  Looked at custom query methods but the data is already
> > > there in an array so I am a little stuck.
>
> > > Here is what is in my view for the friends array and it is working
> > > fine.  Just don't know how to get the admirer as part of it.
>
> > > 
> > > 
> > > 
> > > Html->link(__('View', true), array('controller' =>
> > > 'friends', 'action' => 'view', $friend['id'])); ?>
> > > Html->link(__('Delete', true), array('controller' =>
> > > 'friends', 'action' => 'delete', $friend['id']), null, sprintf(__('Are
> > > you sure you want to delete # %s?', true), $friend['id'])); ?>
> > > 
>
> > > Thanks for any help!
>
> > > Brad
>
> > > Check out the new CakePHP Questions sitehttp://cakeqs.organdhelpothers 
> > > with their CakePHP related questions.
>
> > > 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 
> > > athttp://groups.google.com/group/cake-php?hl=en
>
> > Check out the new CakePHP Questions sitehttp://cakeqs.organdhelp others 
> > with their CakePHP related questions.
>
> > 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 
> > athttp://groups.google.com/group/cake-php?hl=en
>
> Check out the new CakePHP Questions sitehttp://cakeqs.organd help others with 
> their CakePHP related questions.
>
> You received this message because you are subscribed to the Google Groups 
> "CakePHP" group.
> To post to this group, send email t

Re: Help with User - Friend HABTM relationship

2010-05-20 Thread calvin
That's a PHP question, not a Cake question.

If you want to combine the arrays, then just combine them like you
would any other array.

If you have:

$friends = array('friend 1', 'friend 2', 'friend 3', ...);
$admirers = array('admirer 1', 'admirer 2', 'admirer 3', ...);

how would you combine them?

Well, the obvious solution is with array_merge():
$friendsAndAdmirers = array_merge($friends, $admirers);

If you want to filter out duplicates (i.e. if a person is both a
friend and an admirer), then use array_unique() on top of
array_merge().

I would suggest bookmarking--or, better yet, installing the Firefox
search tool for--the PHP Manual:
http://us3.php.net/manual/en/index.php

On May 20, 11:31 am, bradmaxs  wrote:
> Anyone able to help me on this?
>
> On May 18, 4:55 pm, bradmaxs  wrote:
>
>
>
> > Hello All,
>
> > In response to the following post:
>
> >http://groups.google.com/group/cake-php/browse_thread/thread/c8ebc209...
>
> > I have come up with my users having friends and admirers, thank you
> > gentlemen for that.
>
> > I am getting the array for both of them in my dump.
>
> >     [friend] => Array
> >         (
> >             [0] => Array
> >                 (
> >                     [id] => 3
> >                     [username] => artist
>
> >                     [Friend] => Array
> >                         (
> >                             [id] => 1
> >                             [user_id] => 4
> >                             [friend_id] => 3
> >                             [approved] => 1
> >                         )
>
> >                 )
>
> >             [1] => Array
> >                 (
> >                     [id] => 5
> >                     [username] => testing
>
> >                     [Friend] => Array
> >                         (
> >                             [id] => 2
> >                             [user_id] => 4
> >                             [friend_id] => 5
> >                             [approved] => 1
> >                         )
>
> >                 )
>
> >         )
>
> >     [admirer] => Array
> >         (
> >             [0] => Array
> >                 (
> >                     [id] => 5
> >                     [username] => testing
>
> >                     [Friend] => Array
> >                         (
> >                             [id] => 3
> >                             [user_id] => 5
> >                             [friend_id] => 4
> >                             [approved] => 0
>
> > My question, and I think it is simple but I am still a newbie for the
> > most part -
>
> > How do I combine that data in the view to have both friends and
> > admirers as part of the same foreach statement?
>
> > Is that possible?  I have looked at Set::merge and tried that from the
> > controller.  Looked at custom query methods but the data is already
> > there in an array so I am a little stuck.
>
> > Here is what is in my view for the friends array and it is working
> > fine.  Just don't know how to get the admirer as part of it.
>
> > 
> > 
> > 
> > Html->link(__('View', true), array('controller' =>
> > 'friends', 'action' => 'view', $friend['id'])); ?>
> > Html->link(__('Delete', true), array('controller' =>
> > 'friends', 'action' => 'delete', $friend['id']), null, sprintf(__('Are
> > you sure you want to delete # %s?', true), $friend['id'])); ?>
> > 
>
> > Thanks for any help!
>
> > Brad
>
> > Check out the new CakePHP Questions sitehttp://cakeqs.organdhelp others 
> > with their CakePHP related questions.
>
> > 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 
> > athttp://groups.google.com/group/cake-php?hl=en
>
> Check out the new CakePHP Questions sitehttp://cakeqs.organd help others with 
> their CakePHP related questions.
>
> 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 
> athttp://groups.google.com/group/cake-php?hl=en

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

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: Help with User - Friend HABTM relationship

2010-05-20 Thread bradmaxs
Anyone able to help me on this?

On May 18, 4:55 pm, bradmaxs  wrote:
> Hello All,
>
> In response to the following post:
>
> http://groups.google.com/group/cake-php/browse_thread/thread/c8ebc209...
>
> I have come up with my users having friends and admirers, thank you
> gentlemen for that.
>
> I am getting the array for both of them in my dump.
>
>     [friend] => Array
>         (
>             [0] => Array
>                 (
>                     [id] => 3
>                     [username] => artist
>
>                     [Friend] => Array
>                         (
>                             [id] => 1
>                             [user_id] => 4
>                             [friend_id] => 3
>                             [approved] => 1
>                         )
>
>                 )
>
>             [1] => Array
>                 (
>                     [id] => 5
>                     [username] => testing
>
>                     [Friend] => Array
>                         (
>                             [id] => 2
>                             [user_id] => 4
>                             [friend_id] => 5
>                             [approved] => 1
>                         )
>
>                 )
>
>         )
>
>     [admirer] => Array
>         (
>             [0] => Array
>                 (
>                     [id] => 5
>                     [username] => testing
>
>                     [Friend] => Array
>                         (
>                             [id] => 3
>                             [user_id] => 5
>                             [friend_id] => 4
>                             [approved] => 0
>
> My question, and I think it is simple but I am still a newbie for the
> most part -
>
> How do I combine that data in the view to have both friends and
> admirers as part of the same foreach statement?
>
> Is that possible?  I have looked at Set::merge and tried that from the
> controller.  Looked at custom query methods but the data is already
> there in an array so I am a little stuck.
>
> Here is what is in my view for the friends array and it is working
> fine.  Just don't know how to get the admirer as part of it.
>
> 
> 
> 
> Html->link(__('View', true), array('controller' =>
> 'friends', 'action' => 'view', $friend['id'])); ?>
> Html->link(__('Delete', true), array('controller' =>
> 'friends', 'action' => 'delete', $friend['id']), null, sprintf(__('Are
> you sure you want to delete # %s?', true), $friend['id'])); ?>
> 
>
> Thanks for any help!
>
> Brad
>
> Check out the new CakePHP Questions sitehttp://cakeqs.organd help others with 
> their CakePHP related questions.
>
> 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 
> athttp://groups.google.com/group/cake-php?hl=en

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

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


Help with User - Friend HABTM relationship

2010-05-18 Thread bradmaxs
Hello All,

In response to the following post:

http://groups.google.com/group/cake-php/browse_thread/thread/c8ebc2097f8aad11/fae9ec58501534e6?lnk=gst&q=friend#fae9ec58501534e6

I have come up with my users having friends and admirers, thank you
gentlemen for that.

I am getting the array for both of them in my dump.

[friend] => Array
(
[0] => Array
(
[id] => 3
[username] => artist

[Friend] => Array
(
[id] => 1
[user_id] => 4
[friend_id] => 3
[approved] => 1
)

)

[1] => Array
(
[id] => 5
[username] => testing

[Friend] => Array
(
[id] => 2
[user_id] => 4
[friend_id] => 5
[approved] => 1
)

)

)

[admirer] => Array
(
[0] => Array
(
[id] => 5
[username] => testing

[Friend] => Array
(
[id] => 3
[user_id] => 5
[friend_id] => 4
[approved] => 0

My question, and I think it is simple but I am still a newbie for the
most part -

How do I combine that data in the view to have both friends and
admirers as part of the same foreach statement?

Is that possible?  I have looked at Set::merge and tried that from the
controller.  Looked at custom query methods but the data is already
there in an array so I am a little stuck.

Here is what is in my view for the friends array and it is working
fine.  Just don't know how to get the admirer as part of it.




Html->link(__('View', true), array('controller' =>
'friends', 'action' => 'view', $friend['id'])); ?>
Html->link(__('Delete', true), array('controller' =>
'friends', 'action' => 'delete', $friend['id']), null, sprintf(__('Are
you sure you want to delete # %s?', true), $friend['id'])); ?>


Thanks for any help!

Brad

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

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