Re: Converting SQL query to Cake query

2009-03-07 Thread RyOnLife
datetime NOT NULL, >> >>>   PRIMARY KEY  (`id`), >> >>>   FULLTEXT KEY `title` (`title`) >> >>> ) ENGINE=MyISAM  DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC; >> >> >>> PageView belongsTo Page: >> >> >>> CREATE TABLE IF NOT EXIS

Re: Converting SQL query to Cake query

2009-03-07 Thread jason m
int(11) NOT NULL, > >>>   `user_id` int(11) default NULL, > >>>   `user_ip` int(10) unsigned default NULL, > >>>   `created` datetime NOT NULL, > >>>   PRIMARY KEY  (`id`) > >>> ) ENGINE=MyISAM  DEFAULT CHARSET=utf8 ROW_FORMAT=FIXED; > > >>&

Re: Converting SQL query to Cake query

2009-03-06 Thread RyOnLife
gt;>> Page hasMany PageView: >>>>> >>>>> CREATE TABLE IF NOT EXISTS `pages` ( >>>>>   `id` int(11) NOT NULL auto_increment, >>>>>   `user_id` int(11) NOT NULL, >>>>>   `title` varchar(100) NOT NULL, >>>>>   `

Re: Converting SQL query to Cake query

2009-03-06 Thread RyOnLife
gt; PageView belongsTo Page: >>>> >>>> CREATE TABLE IF NOT EXISTS `page_views` ( >>>>   `id` int(11) NOT NULL auto_increment, >>>>   `page_id` int(11) NOT NULL, >>>>   `user_id` int(11) default NULL, >>>>   `user_ip` int(10) unsigned de

Re: Converting SQL query to Cake query

2009-03-06 Thread RyOnLife
>>>   PRIMARY KEY  (`id`) >>> ) ENGINE=MyISAM  DEFAULT CHARSET=utf8 ROW_FORMAT=FIXED; >>> >>> SQL query: >>> >>> SELECT Page.*, COUNT(*) AS views FROM >>> pages AS Page >>> INNER JOIN page_views AS PageView ON Page.id = Pa

Re: Converting SQL query to Cake query

2009-03-06 Thread RyOnLife
;> ORDER BY COUNT(*) DESC   >> LIMIT 10 OFFSET 0; >> >> Returns these fields: >> >> id, user_id, title, slug, created, views >> >> The first five fields are those from the Page model and the sixth field, >> views, is a count of how many times the

Re: Converting SQL query to Cake query

2009-03-06 Thread grigri
age model and the sixth field, > views, is a count of how many times the Page.id primary key is used as a > PageView.page_id foreign key. > > Thanks for the help. I know Cake is supposed to make SQL easier, but I am > having trouble making the jump from SQL to Cake queries where the SQ

Re: Converting SQL query to Cake query

2009-03-06 Thread RyOnLife
t'), > 'order' => array('Post.view_count DESC'), > 'limit' => 10 > ) > ); > > this worked for me. > > > > -- View this message in context: http://n2.nabble.com/Converting-SQL-query-to-Cake-query-tp2434189p2436388.html Sent

Re: Converting SQL query to Cake query

2009-03-06 Thread Stu
$topTen = $this->Post->find('list', array( 'fields' => array('Post.id', 'Post.view_count'), 'order' => array('Post.view_count DESC'), 'limit' => 10 ) ); this worked for me. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Gro

Re: Converting SQL query to Cake query

2009-03-06 Thread RyOnLife
ssociations instead. Once > you have an association, all related data will be returned, simply > contain it or up the recursion. > > > > -- View this message in context: http://n2.nabble.com/Converting-SQL-query-to-Cake-query-tp2434189p2435579.html Sent from the CakeP

Re: Converting SQL query to Cake query

2009-03-06 Thread Miles J
Remove that condition, you should be using associations instead. Once you have an association, all related data will be returned, simply contain it or up the recursion. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups

Converting SQL query to Cake query

2009-03-05 Thread RyOnLife
#x27; => array('Page.id') ) ); Can someone help me refine? Thank you. -- View this message in context: http://n2.nabble.com/Converting-SQL-query-to-Cake-query-tp2434189p2434189.html Sent from the CakePHP mailing list archive at Nabble.com. --~--~-~--~~---