Re: Dynamically Create a Model and Bind it to a Table?
imho creating a single events_data table that uses an event_id foreign key to join back the the events table is the way to go. The events_data table could have a text field that stores serialized arrays. See http://us2.php.net/serialize for details. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Cake PHP" 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 -~--~~~~--~~--~--~---
Re: Dynamically Create a Model and Bind it to a Table?
Hi, Yes the OP's original question can be answered using a single model and before each use setting the table dynamically with $this->model name->setSource(table name); I know, I have an event registration web application (http://www.eventhq.co.uk) running on exactly this model! The reason I chose this route over serialized arrays is because event administrators need to do lots of searches on delegate data and I never really got to grips with searching serialized arrays stored in a DB. Having said that, I am now finding that MrTufty is quite correct about this being a somewhat "tricky" way to go. As a result I am mostly through revising the DB structure to something more similar (but more sophisticated) that MrTufty's outline above and strongly suggest you do the same. Best of luck with your web app. Cheers, Ian --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Cake PHP" 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 -~--~~~~--~~--~--~---
Re: Dynamically Create a Model and Bind it to a Table?
>From everything I've picked up and learned over the years I've been developing, the sort of solution you're suggesting is a definite OMG what the hell are you doing? situation. If you're having to deal with items that may have different information specified, why not do something a little different... Events>Event_Fields In other words, you have an Events table that holds ID numbers and any information that DOES get captured for every single event, and an EventFields table which stores additional information, one item per field. The rough schema would be something like this... Events - id name start_date end_date EventFields -- id event_id field_name field_value You could even set it up so you had another model containing available fields which would specify the types of information you were wanting to capture (just so you can control it a little bit - you could use this model to populate a select box, for example). Then you'd tie that in and add field_id to EventFields in place of field_name, or as well as. Please note that I've not actually developed the code behind this idea, it should work though. I'd be interested to know what other people think... I'm certain it's a better solution than dynamically creating tables and models, but HOW much better? On May 31, 10:17 pm, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote: > That would be an awful lot of tables in your database and it seems > like it might lead to some potentially hairy code. Have you > considered saving the event information as arrays and then saving the > serialized arrays into a single table? I would think it would be a > lot easier to extract varying properties from out of arrays then > tables with different numbers of fields. > > On May 31, 1:05 pm, Wole <[EMAIL PROTECTED]> wrote: > > > I am developing an events registration Web application that collects > > event specific information from registrants and stores the information > > in a database table. The application works by assigning an id to each > > new event then using this id as the name of the table that will hold > > registrants' information. > > > The problem comes when I need to access the data for an event. I > > cannot setup a model file ahead of time because the tables are created > > dynamically . Also, I cannot combine all event data into one table > > because the information collected from each event varies and hence so > > will the number of columns and column data types in each table. > > > Is there a way to dynamically create a model and bind a table to that > > model? In other words, is there a way for me to switch between tables > > using a single model? Thanks. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Cake PHP" 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 -~--~~~~--~~--~--~---
Re: Dynamically Create a Model and Bind it to a Table?
That would be an awful lot of tables in your database and it seems like it might lead to some potentially hairy code. Have you considered saving the event information as arrays and then saving the serialized arrays into a single table? I would think it would be a lot easier to extract varying properties from out of arrays then tables with different numbers of fields. On May 31, 1:05 pm, Wole <[EMAIL PROTECTED]> wrote: > I am developing an events registration Web application that collects > event specific information from registrants and stores the information > in a database table. The application works by assigning an id to each > new event then using this id as the name of the table that will hold > registrants' information. > > The problem comes when I need to access the data for an event. I > cannot setup a model file ahead of time because the tables are created > dynamically . Also, I cannot combine all event data into one table > because the information collected from each event varies and hence so > will the number of columns and column data types in each table. > > Is there a way to dynamically create a model and bind a table to that > model? In other words, is there a way for me to switch between tables > using a single model? Thanks. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Cake PHP" 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 -~--~~~~--~~--~--~---