The array doesn't really look odd, it's doing exactly what Cake normally does and encapsulating results in an array.
If I had to guess it would probably be due to the way your model is structured, and how Cake is building the SQL based on the data you are giving it. Look at the generated query (by setting debug in your core.php file), which will tell you what queries Cake is actually running. My guess is that it's doing the keyword and count in separate queries because of your model. On Dec 11, 8:50 am, matth <matt...@gmail.com> 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 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 -~----------~----~----~----~------~----~------~--~---