Re: Model association issue

2006-09-13 Thread Brian French

Thank you! That fixed my problem perfectly!

AD7six wrote:
> Hi Brian,
>
> You can´t create 2 associations with the same name. You can't say a
> user HasOne Venue and User HABTM Venue - if you don´t give you
> associations unique names the data for both will get mixed together
> (with confusing results as you have seen).
>
> Let me clarify what that means before you say "but I need those
> associations" ;)
>
> Try something like this:
>  class User extends AppModel
> {
> var $name = 'User';
>
> var $hasOne = array('MainFan' => // Changed
> array('className'=> 'Fan',
>   'conditions'   => '',
>   'order'=> '',
>   'dependent'=>  true,
>   'foreignKey'   => 'user_id'
> ),
> 'MainArtist' => // Changed
> array('className'=> 'Artist',
>   'conditions'   => '',
>   'order'=> '',
>   'dependent'=>  true,
>   'foreignKey'   => 'user_id'
> ),
> 'MainVenue' => // Changed
> array('className'=> 'Venue',
>   'conditions'   => '',
>   'order'=> '',
>   'dependent'=>  true,
>   'foreignKey'   => 'user_id'
> ),
> 'MainPromoter' => // Changed
> array('className'=> 'Promoter',
>   'conditions'   => '',
>   'order'=> '',
>   'dependent'=>  true,
>   'foreignKey'   => 'user_id'
> ),
>   );
> var $hasAndBelongsToMany =
> array('Fan','Artist','Venue','Promoter'); // unchanged
> }
>
> If the hasOne is to specify some special relationship, I think that in
> 1.2 you have/will have the possibility to add fields to your join table
> such that you could then have only a HABTM with one of the defined
> relationships having the type "Main" (or whatever is the actual
> meaining of the hasOne as defined here).
>
> Rather than dribble on, after renaming your associations - does that
> work?
>
> HTH,
>
> AD7six
> PS. this is all based upon looking at your debug data and glancing at
> the source - so it could be wrong.
>
>
> >
>
>
>   


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Cake 
PHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/cake-php
-~--~~~~--~~--~--~---



Re: Model association issue

2006-09-13 Thread AD7six

Hi Brian,

You can´t create 2 associations with the same name. You can't say a
user HasOne Venue and User HABTM Venue - if you don´t give you
associations unique names the data for both will get mixed together
(with confusing results as you have seen).

Let me clarify what that means before you say "but I need those
associations" ;)

Try something like this:
 // Changed
array('className'=> 'Fan',
  'conditions'   => '',
  'order'=> '',
  'dependent'=>  true,
  'foreignKey'   => 'user_id'
),
'MainArtist' => // Changed
array('className'=> 'Artist',
  'conditions'   => '',
  'order'=> '',
  'dependent'=>  true,
  'foreignKey'   => 'user_id'
),
'MainVenue' => // Changed
array('className'=> 'Venue',
  'conditions'   => '',
  'order'=> '',
  'dependent'=>  true,
  'foreignKey'   => 'user_id'
),
'MainPromoter' => // Changed
array('className'=> 'Promoter',
  'conditions'   => '',
  'order'=> '',
  'dependent'=>  true,
  'foreignKey'   => 'user_id'
),
  );
var $hasAndBelongsToMany =
array('Fan','Artist','Venue','Promoter'); // unchanged
}

If the hasOne is to specify some special relationship, I think that in
1.2 you have/will have the possibility to add fields to your join table
such that you could then have only a HABTM with one of the defined
relationships having the type "Main" (or whatever is the actual
meaining of the hasOne as defined here).

Rather than dribble on, after renaming your associations - does that
work?

HTH,

AD7six
PS. this is all based upon looking at your debug data and glancing at
the source - so it could be wrong.


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Cake 
PHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/cake-php
-~--~~~~--~~--~--~---



Re: Model association issue

2006-09-12 Thread [EMAIL PROTECTED]

Have you created the intermediate tables for the HABTM tables?  It
seems that the association is working correctly according to the SQL,
but there isn't anything being returned.  So, I don't think it is a
CakePHP problem per se.  But how did you save the records that were
associated in the first place?


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Cake 
PHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/cake-php
-~--~~~~--~~--~--~---



Re: Model association issue

2006-09-12 Thread Brian French




Could someone help me with this?

Brian French wrote:

  I should have elaborated more. When you view that link then go to view a 
particular user:
http://www.myclubbersguide.com/users/view/6
The associations dont seem to be working and i am now getting a php error.

(i have a view method in the users controller, but i commented it out so 
the scaffolding can do its thing)

Brian

AD7six wrote:
  
  
Hi Brian,

I took a peek at your link: I don´t quite understand what the problem
is, can you elaborate?

The sql at the foot of the page shows that sql queries are being
executed for your associations. If you look at the user "test" you can
see that there are results for each association type.

Where is this coming from: array ( [User] => Array ( [id] => 2 [name]
=> Fan User [login] => f etc.

if you have created a method named view in your users controller, there
will be no scaffolding for that action.

cheers,

AD7six
PS. the method pr() gives you shorter debugging code and easier to read
output.




  

  
  




  


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Cake PHP" group.  To post to this group, send email to cake-php@googlegroups.com  To unsubscribe from this group, send email to [EMAIL PROTECTED]  For more options, visit this group at http://groups.google.com/group/cake-php  -~--~~~~--~~--~--~---





Re: Model association issue

2006-09-11 Thread Brian French

I should have elaborated more. When you view that link then go to view a 
particular user:
http://www.myclubbersguide.com/users/view/6
The associations dont seem to be working and i am now getting a php error.

(i have a view method in the users controller, but i commented it out so 
the scaffolding can do its thing)

Brian

AD7six wrote:
> Hi Brian,
>
> I took a peek at your link: I don´t quite understand what the problem
> is, can you elaborate?
>
> The sql at the foot of the page shows that sql queries are being
> executed for your associations. If you look at the user "test" you can
> see that there are results for each association type.
>
> Where is this coming from: array ( [User] => Array ( [id] => 2 [name]
> => Fan User [login] => f etc.
>
> if you have created a method named view in your users controller, there
> will be no scaffolding for that action.
>
> cheers,
>
> AD7six
> PS. the method pr() gives you shorter debugging code and easier to read
> output.
>
>
> >
>
>
>   


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Cake 
PHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/cake-php
-~--~~~~--~~--~--~---



Re: Model association issue

2006-09-11 Thread AD7six

Hi Brian,

I took a peek at your link: I don´t quite understand what the problem
is, can you elaborate?

The sql at the foot of the page shows that sql queries are being
executed for your associations. If you look at the user "test" you can
see that there are results for each association type.

Where is this coming from: array ( [User] => Array ( [id] => 2 [name]
=> Fan User [login] => f etc.

if you have created a method named view in your users controller, there
will be no scaffolding for that action.

cheers,

AD7six
PS. the method pr() gives you shorter debugging code and easier to read
output.


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Cake 
PHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/cake-php
-~--~~~~--~~--~--~---



Re: Model association issue

2006-09-11 Thread Brian French




Scaffolding can display this for you, it's a great tool!

You can view the output here: http://www.myclubbersguide.com/users
It contains the queries being used as well as the print_r() of the
object(s).
The code for the models was in the first email/post in this thread. As
far as i understand it, scaffolding is recursive.

Thank you for your help,
Brian French

Chris Hartjes wrote:

  On 9/8/06, Brian French <[EMAIL PROTECTED]> wrote:
  
  
I am having trouble associating the multiple models i have with each other.

I have a 'User' that hasOne 'Fan','Artist','Venue','Promoter'.
The 'User' also hasAndBelongsToMany of the same ones (like he can
subscribe to them as well as be one/all of them).

I am using the scaffolding to view the associations with them. The
associations are being added ok but when i view the user, the
associations aren't being picked up. Here are the 'User' model and the
'Artist' model (the fan, artist, venue and promoter models all look the
same).

What am i doing wrong?


  
  
I've never used the scaffolding before, but can you show the code that
you think is pulling out the User information?  Also, the database
output (showing all the queries) would be helpfull.  I wonder if the
scaffolding is setting the recursive stuff to -1 and simply showing
User records only...

  


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Cake PHP" group.  To post to this group, send email to cake-php@googlegroups.com  To unsubscribe from this group, send email to [EMAIL PROTECTED]  For more options, visit this group at http://groups.google.com/group/cake-php  -~--~~~~--~~--~--~---





Re: Model association issue

2006-09-11 Thread Chris Hartjes

On 9/8/06, Brian French <[EMAIL PROTECTED]> wrote:
>
> I am having trouble associating the multiple models i have with each other.
>
> I have a 'User' that hasOne 'Fan','Artist','Venue','Promoter'.
> The 'User' also hasAndBelongsToMany of the same ones (like he can
> subscribe to them as well as be one/all of them).
>
> I am using the scaffolding to view the associations with them. The
> associations are being added ok but when i view the user, the
> associations aren't being picked up. Here are the 'User' model and the
> 'Artist' model (the fan, artist, venue and promoter models all look the
> same).
>
> What am i doing wrong?
>

I've never used the scaffolding before, but can you show the code that
you think is pulling out the User information?  Also, the database
output (showing all the queries) would be helpfull.  I wonder if the
scaffolding is setting the recursive stuff to -1 and simply showing
User records only...

-- 
Chris Hartjes

"The greatest inefficiencies come from solving problems you will never have."
-- Rasmus Lerdorf

@TheBallpark - http://www.littlehart.net/attheballpark
@TheKeyboard - http://www.littlehart.net/atthekeyboard

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Cake 
PHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/cake-php
-~--~~~~--~~--~--~---



Re: Model association issue

2006-09-11 Thread Brian French

bump

Brian French wrote:
> I am having trouble associating the multiple models i have with each other.
>
> I have a 'User' that hasOne 'Fan','Artist','Venue','Promoter'.
> The 'User' also hasAndBelongsToMany of the same ones (like he can 
> subscribe to them as well as be one/all of them).
>
> I am using the scaffolding to view the associations with them. The 
> associations are being added ok but when i view the user, the 
> associations aren't being picked up. Here are the 'User' model and the 
> 'Artist' model (the fan, artist, venue and promoter models all look the 
> same).
>
> What am i doing wrong?
>
> (i can supply a url of the scaffolding with the debug set to 2 if you 
> would like)
>
>
>  class Artist extends AppModel
> {
> var $name = 'Artist';
> var $belongsTo = 'User';
> var $hasAndBelongsToMany = 'User';
> }
> ?>
>
>  class User extends AppModel
> {
> var $name = 'User';
>
> var $hasOne = array('Fan' =>
> array('className'=> 'Fan',
>   'conditions'   => '',
>   'order'=> '',
>   'dependent'=>  true,
>   'foreignKey'   => 'user_id'
> ),
> 'Artist' =>
> array('className'=> 'Artist',
>   'conditions'   => '',
>   'order'=> '',
>   'dependent'=>  true,
>   'foreignKey'   => 'user_id'
> ),
> 'Venue' =>
> array('className'=> 'Venue',
>   'conditions'   => '',
>   'order'=> '',
>   'dependent'=>  true,
>   'foreignKey'   => 'user_id'
> ),
> 'Promoter' =>
> array('className'=> 'Promoter',
>   'conditions'   => '',
>   'order'=> '',
>   'dependent'=>  true,
>   'foreignKey'   => 'user_id'
> ),
>   );
> var $hasAndBelongsToMany = array('Fan','Artist','Venue','Promoter');
> }
> ?>
>
>
>
>
>
> >
>
>   

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Cake 
PHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/cake-php
-~--~~~~--~~--~--~---



Model association issue

2006-09-08 Thread Brian French

I am having trouble associating the multiple models i have with each other.

I have a 'User' that hasOne 'Fan','Artist','Venue','Promoter'.
The 'User' also hasAndBelongsToMany of the same ones (like he can 
subscribe to them as well as be one/all of them).

I am using the scaffolding to view the associations with them. The 
associations are being added ok but when i view the user, the 
associations aren't being picked up. Here are the 'User' model and the 
'Artist' model (the fan, artist, venue and promoter models all look the 
same).

What am i doing wrong?

(i can supply a url of the scaffolding with the debug set to 2 if you 
would like)





array('className'=> 'Fan',
  'conditions'   => '',
  'order'=> '',
  'dependent'=>  true,
  'foreignKey'   => 'user_id'
),
'Artist' =>
array('className'=> 'Artist',
  'conditions'   => '',
  'order'=> '',
  'dependent'=>  true,
  'foreignKey'   => 'user_id'
),
'Venue' =>
array('className'=> 'Venue',
  'conditions'   => '',
  'order'=> '',
  'dependent'=>  true,
  'foreignKey'   => 'user_id'
),
'Promoter' =>
array('className'=> 'Promoter',
  'conditions'   => '',
  'order'=> '',
  'dependent'=>  true,
  'foreignKey'   => 'user_id'
),
  );
var $hasAndBelongsToMany = array('Fan','Artist','Venue','Promoter');
}
?>





--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Cake 
PHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/cake-php
-~--~~~~--~~--~--~---