Friday, January 2, 2009

CakePHP models

I'm having a little trouble setting up my models properly so that I
retrieve my data. This really wasn't an issue until I started messing
around with the paginate helper.

I have two tables:
hits: col1|col2|col3|item_id
items: id|title

How do I set up my models so that I can sort by popularity (as in how
many times the id appears in the table hits)?

Just to be clear I can formulate the actually query in full sql,
that's not really an issue... I have that knowledge. My trouble is
figuring out how the paginate helper formulates which tables to
include in the FROM clause.

I have my HitModel setup with $belongsTo and ItemModel setup with
$hasMany.

In debug mode I can see that Cake uses "DESCRIBE items" and "DESCRIBE
hits" but I still can't figure out how to actually get hits into
paginate's FROM clause.
--~--~---------~--~----~------------~-------~--~----~
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: