Well, the table looks more like this:

user_id | web_page_type_id | url
-----------------------------------------------------------------------
    7      |          6                 | firstdomain.com
    7      |          6                 | second.com

So the two are unique, but I see what you're saying.

I did originally have it setup in such a way that it wasn't a typical
join table (as nachopitt suggested); however, was running into
problems with saving in one fell swoop and wanted to give the "HABTM
save setup" a try (as described everywhere).

Might have to go back to the previous method.

On Oct 4, 7:33 am, nachopitt <[EMAIL PROTECTED]> wrote:
> Yeah, teknoid has a point. Your relation/association is not supposed
> to work in that way. Normally, in a non CakePHP enviroment, a
> joinTable has the 2 foreign keys and they set as the "primary key"
> column. You don“t have the "id" column that CakePHP expects to have
> and then the foreign keys... thats why the "uniqueness" of the
> records.
>
> Personally i would change the schema of you database for something
> like
>
> users
> web_pages (holding the url, title, etc)
> web_page_types (holding the name of the webpage type)
>
> And the associations
>
> user hasMany webpages
> webpage belongsTo user
> webpage belongsTo webpageType
>
> On Oct 3, 6:37 pm, teknoid <[EMAIL PROTECTED]> wrote:
>
> > Goes to show I should read more carefully :)
> > I guess the title of the post made me jump the gun...
>
> > You say "an user has 2 of the same webpage_type"
>
> > Does it mean that in your join table you have something like: ?
> > user_id | web_page_type_id
> > -----------------------------------------
> >     7      |          6
> >     7      |          6
>
> > On Oct 3, 6:27 pm, Brenton B <[EMAIL PROTECTED]> wrote:
>
> > > Well, assuming the Docs are correct (and I understand it properly),
> > > that should only apply to updates ("If true (default value) cake will
> > > first delete existing relationship records in the foreign keys table
> > > before inserting new ones, when updating a record. So existing
> > > associations need to be passed again when updating").
>
> > > However, in my circumstance, I'm just retrieving information ...
>
> > > Debug SQL shows the (as expected) query of getting all webpages &
> > > types based on the user_id, and it retrieves all the information
> > > that's needed; however, by the time I get to the view (where I have a
> > > `pr()`), I've magically lost one of 'em - well, actually, any
> > > subsequent webpage_type record that has the same id.
>
> > > Conventions: Yeah, I know those were just there, left over from
> > > scaffolding, so figured no harm in leaving 'em ...
>
> > > On Oct 3, 3:19 pm, teknoid <[EMAIL PROTECTED]> wrote:
>
> > > > Do you know what 'unique'=>true does?
>
> > > > Btw, there really isn't any need to define default values for your
> > > > associations if you follow the conventions.
>
> > > > On Oct 3, 6:10 pm, Brenton B <[EMAIL PROTECTED]> wrote:
>
> > > > > Ok, so here's the scenario ...
>
> > > > > A user can have multiple webpages in their account, and when they set
> > > > > them up, they must choose the type (ex: blog, gallery, etc). So User
> > > > >HABTMwebpage_type ... where users_webpage_types has additional fields
> > > > > for URL, title, etc.
>
> > > > > The thing I'm running into is upon retrieving: If an user has 2 of the
> > > > > same webpage_type, it performs the SQL to get 'em all, but once it's
> > > > > done it's magic, it only has the first record. I'm assuming this is
> > > > > due to the occurrence of the same webpage_type_id, but still lost ...
>
> > > > > User::
>
> > > > >         var $hasAndBelongsToMany = array(
> > > > >                         'WebpageType' => array('className' => 
> > > > > 'WebpageType',
> > > > >                                                 'joinTable' => 
> > > > > 'users_webpage_types',
> > > > >                                                 'foreignKey' => 
> > > > > 'userr_id',
> > > > >                                                 
> > > > > 'associationForeignKey' => 'webpage_type_id',
> > > > >                                                 'with' => 
> > > > > 'UsersWebpageType',
> > > > >                                                 'unique' => true,
> > > > >                         ),
>
> > > > > WebpageType::
>
> > > > >         var $hasAndBelongsToMany = array(
> > > > >                         'User' => array('className' => 'User',
> > > > >                                                 'joinTable' => 
> > > > > 'users_webpage_types',
> > > > >                                                 'foreignKey' => 
> > > > > 'webpage_type_id',
> > > > >                                                 
> > > > > 'associationForeignKey' => 'user_id',
> > > > >                                                 'with' => 
> > > > > 'UsersWebpageType',
> > > > >                                                 'unique' => true,
>
> > > > > UsersWebpageType::
>
> > > > >         var $belongsTo = array(
> > > > >                         'User' => array('className' => 'User',
> > > > >                                                                 
> > > > > 'foreignKey' => 'user_id',
> > > > >                                                                 
> > > > > 'conditions' => '',
> > > > >                                                                 
> > > > > 'fields' => '',
> > > > >                                                                 
> > > > > 'order' => ''
> > > > >                         ),
> > > > >                         'WebpageType' => array('className' => 
> > > > > 'WebpageType',
> > > > >                                                                 
> > > > > 'foreignKey' => 'webpage_type_id',
> > > > >                                                                 
> > > > > 'conditions' => '',
> > > > >                                                                 
> > > > > 'fields' => '',
> > > > >                                                                 
> > > > > 'order' => ''
> > > > >                         )
> > > > >         );
>
> > > > > Seriously confused ....
>
> > > > > I've searched the group, and came up empty handed - probably due to
> > > > > diff keywords.
>
> > > > > Cheers.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to