I think this is because it's nigh on impossible to determine the table that a function, like COUNT or SUM etc, is getting its data from.
For more information and some work-arounds, see: http://groups.google.com/group/cake-php/browse_thread/thread/2fa2cd69422dfcf/81e7a5ea50266a15 On Dec 11, 4:50 pm, matth <[email protected]> wrote: > The keywords query in the view() function is returning the following > array: > Array ( [Hit] => Array ( [keyword] => banana ) [0] => Array ( [count] > => 1 ) ) > > I am going for: Array ( [Hit] => Array ( [keyword] => banana, [count] > => 1 ) ) > > class ItemsController extends AppController > { > var $name = 'Items'; > var $uses = array('Item', 'Hit'); > function index() > { > $this->pageTitle = 'Items'; > #FIND UNIQUE! > #$this->set('items', $this->Item->findAll()); > $this->set('items', $this->Item->query("SELECT * FROM > items")); > } > > function view($item_id = null) > { > $this->pageTitle = 'Item #'. $item_id; > > $this->Item->id = $item_id; > $this->set('item', $this->Item->read()); > > $this->set('keywords', $this->Hit->find('all', array > ('conditions'=>'item_id="'.$item_id.'" AND keyword !=""', > 'fields'=>array('DISTINCT keyword','COUNT(*) AS count'), 'group'=>array > ('keyword'), 'order'=>'count DESC'))); > } > > } > > Table Structure: > hits > -------- > hit_id > ipa > referer > domain > date > item_id > keyword > > items > --------- > item_id > title > > Is my query incorrect? Could it be a problem with my model? --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~----------~----~----~----~------~----~------~--~---
