Saturday, October 4, 2008

hasMany unsure

Hi, I'm trying to connect 2 tables together with "has" many, basically what I want to do is select all the votes from the votes table and order them by total votes.  How exactly am I supposed to do that using cakes hasMany relation.

I have the following:

<?php
class Webview extends AppModel {

    var $name = 'Webview';
    var $useTable = 'websites';
    var $hasMany = array(
        'votes' => array(
            'classname' => 'Votes',
            'foreignKey' => 'website_id',
            'fields' => array('COUNT(votes.*) as TOTAL','votes.id'),
        )
    );
   
}
?>

Then I just call the find function get all errors, blah people said don't use the query function so I'm giving this hasmany thing a try and it failed.  Any ideas on how to do what I'm trying to do?

--
Join cleanscript.com Come here for professional PHP coding.

--~--~---------~--~----~------------~-------~--~----~
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: