I'd say that what is best depends on how many preferences you anticipate in your application.
One field per preference in the user's table works fine for a very few but can start looking messy after a while. I have seen e-commerce applications with 50+ fields in the products table (is_hardware, amd_socket_compatible, usb, ...). The "amd" boolean is only relevant for motherboards and CPUs, "usb" only for external disks and other peripherals. They work but to me it just looks a mess. :) If you think you will be adding a bunch of other preferences soon then you might want to think of a more flexible setup. When things are just a little more complex that 2-3 preferences I have used a serialized array in a single field. This has major drawbacks if you ever want to query the data but for preferences I have sometimes chosen them because they can store hierarchies of preference data. This would be comparable to data in a Cake session or the Configure class only stored in the database. If you anticipate more preferences and possible more dynamic data stored you can look at a technique where you have a table that stores key, value pairs linked to the User. That way only set and relevant preferences will be stored but there might be a bit more sql trickery. I use this when I import meta-data from uploaded files and the kinds and amount of data can vary greatly. This will sort-of be a virtual dynamic table of a table. There was some posts about it last fall or winter... might find them in a search. /Martin On Sep 2, 7:01 pm, "Dave Maharaj :: WidePixels.com" <[email protected]> wrote: > I have a Posts section which has a bookmark feature for users to save the > posts they like.... > > Now I want to add a preferences section to the users table with a field > "display" which will be a bool true / false so when they view posts it will > either pull all posts or ones they have not bookmarked only based on the > "display" value and pass those posts to pagination. > > What would be the best way to do this? > > I was thinking: > in the query I have contain bookmark which gets the post_id > so if the Bookmark.post_id is in the Post.id remove it from the array > > What would anyone suggest? > > thanks > > Dave --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
