I was wondering if anyone could give me a nice simple example of how to save a multi select box to database.
Or even just a general array to database as this is something I need to learn. Any help would be appreciated.
I was wondering if anyone could give me a nice simple example of how to save a multi select box to database.
Or even just a general array to database as this is something I need to learn. Any help would be appreciated.
I find it helpful to examine the $_POST array and see how the data is structured.
The gist of it is that you loop through the data, either directly using $_POST (i used this style in Yii 1.1) or the request data shorthand. Now… usually when I have an array of checkboxes it is modeled in SQL as a one:many relationship. So, for each iteration, we create a new model of the associated data table, assign the foreign key, and save() it.