with dynamic names? That might work...
However, I'm not sure why this is necessary - If you know enough about
the page to widget relations to serialise it in an array, surely you
know enough to do the same things with a proper DB relation?
On Apr 30, 4:54 pm, Evert <Compa...@gmail.com> wrote:
> My site is build with a lot of plugins.
> Now, I used to use a 'pages' table that had the column called
> 'widgets'
> the column contained a serialized array which contained information
> about which widgets (models) should be in that page. Something like
> this:
>
> array(
> [0] => array(
> 'name' => 'content'
> 'args' => array(
> 'id' => 1
> )
> )
> [1] => array(
> 'name' => 'comments'
> 'args' => array(
> 'group_id' => 1
> )
> )
> )
>
> Then I had plugin-models called 'Content' and 'Comments' which had
> tables like 'content_data', 'content_settings', 'comments_data' and
> 'comments_settings'.
>
> Now someone told me I should never ever have an array inside a
> database-table.
> So I tried to do it without an array, and got up with this database
> structure:
>
> A table called 'pages'
> A table called 'widgets' with columns called 'id' and 'page_id'
> And all my widgets ('content_data' and 'comments_data') got an extra
> column called 'widget_id'
>
> Now I wanted to give my widgets a
> var $belongsTo = array('widgets');
>
> But I can't give my 'widgets'-model a
> var $hasMany = array(?);
> Cause I don't know which widgets are on a page.
> Of course, I could try to associate it with EVERY widget (although I
> wouldn't know how), but that would be very slow when I get a lot of
> widgets.
>
> So, how do I give it the right $hasMany-var?
--~--~---------~--~----~------------~-------~--~----~
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+unsubscribe@googlegroups.com
For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---
No comments:
Post a Comment