Hi amitava,
>> Ok, first thing is I think it might be a good idea to not have
>> duplicate association names, you Currently have
>>
>> Bid belongsTo User,BidSession
>> BidSession hasMany Bid
>> BidSession hasAndBelongsToMany User
>> User hasMany Bid
>> User hasAndBelongsToMany BidSession
>>
>> I really think you'd be better off calling the last one
>> BidSessionRegistrations, to avoid confusion internally.
>
> Well, don't I need to declare the habtm relationship in both the
> models if I want to list students registered for a particular session
> as well as list bid sessions a particular student has registered for
> (to be used in a different context)?
that wasn't really my point, from your model setup something struck me
as odd, though looking at it now I can't see it, so perhaps it's fine!
>> When you do (line 116):
>>
>> $users = $this->BidSession->User->find('list');
>>
>> you aren't asking cake to grab the users from a particular session,
>> you are tunnelling directly to the User model and finding ALL users!
>> The easiest way to get the Users for a particular BidSession is let
>> cake do it for you by increasing the recursive level above 0 on the
>> BidSession model. If you have linked up any users to a BidSession,
>> they will automatically be retrieved by cake unless you ask them not
>> to be when you find the BidSession record.
>
> OK ... and I can get the list of associated _users_ only (and not
> bids) for a bid session using bind/unbind or Containable behavior,
> right?
no!! you don't need to. The associated users will automatically be
returned by cake, no subsequent query (call to a find method) or
unbind/bind required. I suggest you analyse the the data outputted by:
debug($this->Big->find('first', array('Bid.id'=>$bid_id, 'recursive'=>3));
>> I think the problem with line 170:
>>
>> $bidSessionRegistrations = $this->User->BidSessionRegistration->find('list');
>>
>> is that cake defaults to using 'id', 'name' for the fields in
>> find('list'), if you want need something other than that you have to
>> explicitly tell cake.
>
> Yeah, my bad ... the documentation says so ... and of course the bake
> script wouldn't know which fields I'd want ... but may be it can
> default to the two FKs (since it knows this is a join table)?
I don't think you can do a find(list) on a join table directly.
Generally I do one of two things.
a) When I have to deal with the data in the join table, I 'massage'
the data (using the Set class) into the list I need (that's the
example I provided) - I would use this to obtain the 'selected'
indexes when dealing with a multiple select tag
b) grab all the records to populate a multiple select tag
neither of the above ever require me to directly access the join
model, it's all handled automatically.
> I'll try re-running the bake script on a fresh "install" and see if it
> picks up the associations properly.
I think you'd be better off skipping bake and getting your hands
dirty. writing cake code is pretty quick, and you'll learn how things
are tied together much better this way. Start at the blog tutorial
http://book.cakephp.org/view/219/blog and expand from there.
> I would like to have your opinion on the following points:
> A. You'll notice that User--<Bid>--BidSession is a "through"
> association, so I could use the "with" condition ... my question is,
> will it be too confusing if I have multiple habtm associations between
> the same two models? Anyway I'll try this and post what I find.
You'll need to use with if you want extra columns in your habtm. it
works really well, though I don't follow why you need multiple habtm
associations between the same two models with 'with'. why not forget
the with and set the condition on each habtm.
var $hasAndBelongsToMany = array(
'UsersCalledJoe'=>array(
'model'=>'User'
'joinTable' => 'bid_session_registrations',
'name'=>'Joe'
)
);
> B. We authenticate logins against our Exchange server, so the users
> table doesn't store any passwords ... how difficult is it to use the
> Auth component in this setup? Am I better off writing my own
> authentication routine?
I think that's best posted as a separate message, as I don't know
anything about exchange server, sorry!
hope this helps,
jon
--
jon bennett
w: http://www.jben.net/
iChat (AIM): jbendotnet Skype: jon-bennett
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---