I think you should specify the relation in the `job_title` model
http://book.cakephp.org/2.0/en/models/associations-linking-models-together.html#hasone
Then the find() method should return you the related values as
associative arrays.
To adapt & normalize the results, eg. a single array, look at model
callback (eg. afterFind)
http://book.cakephp.org/2.0/en/models/callback-methods.html
Il 28/12/2011 02:18, robbie ha scritto:
> Hi folks,
>
> I imagine a good search would help me find the answer to my problem,
> but unfortunately, I don't know the words to use to describe my
> problem. So, I'll describe it here and seek either the terminology I
> need to learn more or possibly the solution.
>
> I'm completely new to CakePHP but somewhat familiar with PHP and
> MySQL. Familiar enough with the later, that I've decided I need to
> first to make a better application.
>
> Imagine I have the following database tables.
>
> TABLE job_title
> id
> desc
> level
>
> TABLE job_levels
> id
> desc
>
> A record in the job_title table would look something like:
>
> id = 1
> desc = CakePHP Developer
> level = 3
>
> And the job_levels table has the following data
>
> id = 3
> desc = Senior
>
> So, in this case, when I do a join in MySQL, I'd get a job_title
> record that looks something like:
> id = 1
> desc = CakePHP Developer
> level = 3
> desc = Senior
>
> Basically, I'm substituting the job level id for the job level desc.
>
> Now, how do I do the same in CakePHP?
>
> I built put an association in the model for Job but that doesn't
> return exactly what I want. Essentially, for each job, I'd like to
> have the level description available in the model. At least I think
> this is what I want. Maybe there is some concept I'm missing that
> would make this unnecessary.
>
> Hopefully this makes sense. Any help or advice is greatly
> appreciated.
>
> robbie
>
--
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
No comments:
Post a Comment