Hi, I think that can be achieved by adding this attribute to the parent model instead.
Then all your models will inherit this property. 2008/9/18 Joe <[EMAIL PROTECTED]> > > Sounds like something that could be easily handled with EAV modeling. > I wrote about it awhile ago. http://blog.joebeeson.com/?p=30 > > There are plenty of other sources of good information on the topic. > With EAV you keep the number of tables small and it's still pretty > fast with smart indexing while allowing you to keep your schema > dynamic. > > On Sep 17, 8:49 pm, bMilesp <[EMAIL PROTECTED]> wrote: > > This is an interesting problem that i believe can have a reasonable > > solution using cakephp. i'm not going to get into the background, but > > it stems from this idea: > > > > http://fornicode.com/2008/03/18/cakephp-a-has-either-association/ > > > > now for the business. > > > > my current company has a custom built CMS and i've convinced them to > > start implementing cakephp for it. It's not going to be a complete > > overhaul, but a slow migration. The CMS manages multiple products with > > tons of different attributes for an online store. so the data model > > consists of multiple product tables and a product category table. > > > > Over time, product pricing became an issue since there were multiple > > price mechanisms involved for different products, so we came up with a > > solution to create a pricing system that was separate from the product > > tables. This could allow for different pricing for time based events > > as well as flat priced items. to match the pricing model with the > > specific product, one simply needs to pass the product_id and the > > product_category_id, then all relevant pricing can be retrieved. Now, > > this method worked so well, we started creating other general > > separations, like an image table and a google_maps table, each having > > a product_id and product_category_id field to relate the data. > > > > following this pattern, we now have multiple "attribute" tables, and > > will probably add more, like videos, artices,etc. > > > > Now for the Cake > > > > so we have over 50 product categories and associated tables. I've > > created models in cakephp for a bunch of these products and came > > across... "The Issue": I need to add a new "attribute" table to all > > these models. So instead of going through each of these 50 model files > > and adding the hasMany association i could do... well... i'm not sure. > > > > luckily i'm just foreseeing this problem, which is very likely to > > happen, and would like to ask for a solution. > > > > Here's the mechanics: > > > > each of these attribute tables requires a product_category_id. So i > > pass that in, say, the Shoe model, which has a product_category_id = > > 12. The Shoe model has all the attribute tables, but i will only show > > the Image, and Video association examples for brevity: > > > > var $hasMany = array( > > 'Image' => array( > > 'className' => 'Image', > > 'conditions' => 'product_category_id = 12', //12 is the shoe product > > category > > ) > > ); > > > > var $hasMany = array( > > 'Video' => array( > > 'className' => 'Video', > > 'conditions' => 'product_category_id = 12', > > ) > > ); > > > > etc. > > > > as you can see, the product_category_id must be passed in each product > > model, so if i have over 50 products besides shoes, adding a new > > attribute table would be cumbersome to say the least. > > > > 1) I've thought of using an include file, but you cannot pass a > > variable when defining class vars, so replacing the '12' with a > > $variable is not possible. > > > > 2) I've thought of having a dummy table to relate to all the > > "attribute" tables, and maybe simply including the dummy table in my > > product models. But this doesn't seem to be a possible solution to my > > knowledge. > > > > 3) so could some kind of model behavior be a solution? Not sure how to > > go about this option. > > > > If anyone could point me in a good direction, i think this would be a > > great advantage to use cakephp over our custom built CMS. Thanks to > > all! > > > --~--~---------~--~----~------------~-------~--~----~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~----------~----~----~----~------~----~------~--~---