Re: Reading name using city_id in the user (main) tabl, Reading name from id in the main table(controller)
I have read these and tried a couple ways already. The difference here
is that city_id,secretquestion_id are part of my main table and my
controller is on the main table. Where as in that material, user_id
(of the main table) is part of the secondary info table (so user_id is
foreign key).
That's where my $this->user->find() is failing to retrieve the data
from secondary table.
-BC
On Feb 20, 5:00 pm, Tilen Majerle <tilen.maje...@gmail.com> wrote:
> if you have relations in models created, than this should be automatically
>
> so, probably
> User BelongsTo City
> Secretquestion belongsTo City
>
> City hasMany User
> City hasMany Secretquestion
>
> http://book.cakephp.org/2.0/en/models/associations-linking-models-tog...
>
> read here how to read data :)
>
> --
> Lep pozdrav, Tilen Majerlehttp://majerle.eu
>
> 2012/2/20 Blues Clues <bluesclu...@gmail.com>
>
>
>
>
>
>
>
> > Hi
> > I want to use cakephp model behaviour to do this. Can you help?
>
> > I have a user table which stores id(s) for city, secretquestion etc.,
> > so my 'user' table has city_id and secretquestion_id and the actual
> > names/texts for these are stored in City & Secretquestion tables
> > respectively.
>
> > Now, I am coding UsersController. When I read my User table, I get
> > these IDs obviously. But I need to retrieve these names (City Name,
> > Secretquestion Text) for subsequent use.
>
> > How can I do that? Can someone shed light on the steps involved?
>
> > I can simply write a SQL and do that but I want to utilize CakePHP
> > Model functionality and handle this the CakePHP way.
>
> > Thanks
> > -BC
>
> > --
> > Our newest site for the community: CakePHP Video Tutorials
> >http://tv.cakephp.org
> > Check out the new CakePHP Questions sitehttp://ask.cakephp.organd help
> > others with their CakePHP related questions.
>
> > To unsubscribe from this group, send email to
> > cake-php+unsubscribe@googlegroups.com For more options, visit this group
> > athttp://groups.google.com/group/cake-php
--
Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org
Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions.
To unsubscribe from this group, send email to
cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php
0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home