title, and description. I also have a table containing custom field
data, so that I may create custom form fields on a per category basis,
and I have a third table that contains the answers associated with
particular posts, which contains a record for every custom form field
each time a post is submitted that utilizes custom form fields. Each
record in the answer table has a post_id and a field_id, and a value.
Now, lets say I want to display all the posts for a particular
category on a page. I can use cake's find method to pull the data and
filter it to only select the posts with a certain category_id, that's
easy. I have setup a HABTM relationship between the field model and
the post model (not sure if that's what needs to be done, but it seems
to be selecting the data I need at this time). On the page that is
displaying the post data, I am also displaying select custom field
names as additional columns.
By the way, I'm selecting all this data inside the posts controller
For instance:
ID | Title | Manufacturer | Age | Condition
-----------------------------------------------------------------------------
The first 2 columns are from the post table and the last 3 are labels
that I selected from the field table. Then, I am able to select the
data from the post table and the associated answer data from the
answer table.
For istance (these values are just for demonstration, I'm really using
IDs to represent data that's repeated)::
ID | Title | Manufacturer | Age | Condition
-----------------------------------------------------------------------------
1 | Test 1 | Company 1 | 2 years | Very Good
2 | Test 2 | Company 2 | 5 years | Good
3 | Test 3 | Company 3 | 12 years | Fair
I know how to order the results by a field inside the posts table,
such as id or title, but I cannot for the life of me figure out how to
order these results by a field inside the field table....and I may be
completely crazy by thinking it can be done..maybe I'm missing
something obvious, dunno. For instance, I would like to be able to
sort these results by manufacturer, by age, or by condition. I think
I'm just forgetting something but since I can't seem to rack my brain
around it, can anyone out there point me in the wrong direction or let
me know if something like this is even possible, or if it is possible
but not with the database structure I'm using?
Thanks
Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions.
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+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
No comments:
Post a Comment