I use serialization when:
1.
The array is a preference hash (used for settings in plugins). This is
a kind of caching to the db if you will.

2.
The array is a very complex or in some other way messy structure that
is only stored for logging purposes. One example is the rats-nest
called MM7 (SOAP xml-data for MMS services) and similar data that
would make up 70% of your database schema if stored in tables and
fields.

But I agree that is has major drawbacks if and when you find the need
to actually search through data stored this way.

/Martin


On Aug 10, 5:25 pm, CobaltShark <cobaltsharksoftw...@gmail.com> wrote:
> It is always a bad idea to try and squeeze lists into a single field.
> It will inevitably lead to you pulling your hair out in the future.
> Anyone who is tempted to store comma separated lists in a field
> because its 'easier' should spend a few minutes reading about database
> normalization.http://dev.mysql.com/tech-resources/articles/intro-to-normalization.html
> is a great place to start. Following a few simple 'rules' when
> developing your tables will save you the headache of trying to write
> overly complex SELECT queries in the future.
>
> On Aug 6, 2:19 am, Rawna <asumaw...@gmail.com> wrote:
>
>
>
> > How do I store an array into the database?
> > Here's the view:
> >                 echo $form->input('name');
> >                 echo $form->input('bio');
> >                 echo $form->input('book_id', array('multiple' => true));
>
> > What if I got multiple books? How do I store them in the database?
> > Whenever I tried saving the entry I get these errors:
>
> > Notice (8): Array to string conversion
> > Warning (512): SQL Error: 1054: Unknown column 'Array' in 'field list'
> > Query: INSERT INTO `authors` (`name`, `bio`, `book_id`) VALUES ('Chuck
> > Palahniuk', 'Great writer', Array)
>
> > I created the BookController using bake BTW.
>
> > Thanks in advance!
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to