Re: storing user_ids
On Sat, Jan 3, 2009 at 9:02 PM, ymadh wrote: > > Each record of the associated tables. So if a client is created under > a logged in user, I want it to autopopulate the db with user_id which > is in the session. That way each user only sees their clients..make > sense? My client table would have client info, and of course a user_id > field. > > I didn't link the models ... Would that create extra overhead on every > page that needs that user_id field?? If you have a user_id column in a model's table, then you should associated it with the User model. That way, you'll have to do very little to store it. In your view, you can add a hidden field: echo $form->hidden('User.id', array('value' => $session->read('User.id'))); That will give your controller a $data array something along these lines: array( 'YourModel' => array( 'some field' => 'some value', ... ), 'User' => array( 'id' => 42 ) ) That presupposes that only logged-in users will use that form. And, again, that this model is properly associated with User. As for overhead, you can use the ContainableBehavior to adjust what Cake queries the DB for. --~--~-~--~~~---~--~~ 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: storing user_ids
Each record of the associated tables. So if a client is created under a logged in user, I want it to autopopulate the db with user_id which is in the session. That way each user only sees their clients..make sense? My client table would have client info, and of course a user_id field. I didn't link the models ... Would that create extra overhead on every page that needs that user_id field?? Thanks! --~--~-~--~~~---~--~~ 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: storing user_ids
On Sat, Jan 3, 2009 at 8:18 PM, ymadh wrote: > > I want to have the logged in user information stored with each > record. Is there a way to set this on the controller or do I have to > rely on hidden fields in the views? > Each record of what? Is there a user_id column in the table? Is the User model associated with it? --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
storing user_ids
I want to have the logged in user information stored with each record. Is there a way to set this on the controller or do I have to rely on hidden fields in the views? Thanks! --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---