RE: Alternate Pagination question
Thanks for the code. I ended up with something very similar, I just ran a query finding first record starting with letter while looping thru the alphabet (cache query so it only runs once like yours) then pass it off as an array 0 or 1 for each letter if has record it becomes a link if 0 then just the letter to my alpha_paging helper and that's pretty much it. Dave Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. 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
Re: Alternate Pagination question
On Fri, Sep 3, 2010 at 4:52 PM, Dave Maharaj wrote: > Has anyone created, thought of , started on the idea of an alphabetical > character paging system? > > So rather than 1 | 2 | 3 it spits out A |B |C? I did that awhile ago. It originally was a non-Cake site and I had most of the legwork done directly in Postgres. When I moved the site to Cake I had to switch to MySQL. But it all works very well. It's lengthy, so I posted it here: http://pastebin.com/F8gNPVNp I edited things a wee bit to generalise because the actual app is pretty complex. Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. 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
Re: Alternate Pagination question
The most efficient way database-wise would be to have a char(1) database column that you populate with whatever the first letter of the field you're using... that way it could be indexed and easily counted. It would be slightly slower when saving data but (I assume) much faster retrieving it. If you didn't want to do that, you could use the mysql substring function: Here is mysql the query string(tested) SELECT SUBSTRING(name, 1, 1) as letter, COUNT(SUBSTRING(name, 1, 1)) as count FROM people GROUP BY letter ORDER BY letter; Here is a cake query(untested) $this->People->find('list', array( 'fields' => array('SUBSTRING(name, 1, 1) as letter', 'COUNT(SUBSTRING(name, 1, 1)) AS COUNT'), 'group' => 'letter', 'order' => array('letter' => 'ASC') ) ); On Sep 3, 4:02 pm, "Dave Maharaj" wrote: > Sorry , my first thought would be to do a looping find->first of each letter > and so if it found a record starting with A set that link true, if nothing > for B then just the letter no link and co on... > > The only problem I see is 26 queries just to build the paging links. > > Other ideas? > > Thanks > > From: Dave Maharaj [mailto:m...@davemaharaj.com] > Sent: September-03-10 6:22 PM > To: cake-php@googlegroups.com > Subject: Alternate Pagination question > > Has anyone created, thought of , started on the idea of an alphabetical > character paging system? > > So rather than 1 | 2 | 3 it spits out A |B |C? > > The ABC part seems rather simple just getting the letters to be links if > there are records for that letter seems to be the real issue. Any ideas on > how to approach this one before I start? > > Thanks, > > Dave > > Check out the new CakePHP Questions sitehttp://cakeqs.organd help others > with their CakePHP related questions. > > 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 > athttp://groups.google.com/group/cake-php?hl=en Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. 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
RE: Alternate Pagination question
Sorry , my first thought would be to do a looping find->first of each letter and so if it found a record starting with A set that link true, if nothing for B then just the letter no link and co on... The only problem I see is 26 queries just to build the paging links. Other ideas? Thanks From: Dave Maharaj [mailto:m...@davemaharaj.com] Sent: September-03-10 6:22 PM To: cake-php@googlegroups.com Subject: Alternate Pagination question Has anyone created, thought of , started on the idea of an alphabetical character paging system? So rather than 1 | 2 | 3 it spits out A |B |C? The ABC part seems rather simple just getting the letters to be links if there are records for that letter seems to be the real issue. Any ideas on how to approach this one before I start? Thanks, Dave Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. 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 Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. 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