If you want to record all of that information then yes that would be
the best way to do it.

A simpler method would be to give each publication an integer field,
and create two functions (vote_up/vote_down), I have attached sample
code below for vote_up function (vote down would be the same, but
rating would obviously be minus 1).

// retreive id and store in a variable for use later on:
$publication_id = $this->Publication->read(null, $id);
// Retrieve "ratings" field, and add 1 to it:
$newRating = $this->Publication->field('rating') + 1;

// Now try and save the new ratings number, check if the ID exists
first:
if (!empty($tip_id)) {
// set flash message
$this->Publication->saveField('rating', $newRating);
$this->Session->setFlash(__('Success! Thankyou for rating.',
true));
} else {
//  otherwise throw out error message:
$this->Session->setFlash('Sorry, we couldn\'t register that rating,
please try again.');
}



You could probably use some of that even if you decide to use a
seperate table. If you do use a seperate table, countcache would be
worth looking into to count the number of votes (http://
book.cakephp.org/view/816/counterCache-Cache-your-count).

I've not been baking long, but I think this is correct, you will have
to excuse me if not!
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to