views:

59

answers:

3

i code some configuration setting. And need those values to be load, everytime my webapp start. yes, it's somekind autoload setting.

But, right now, i have to choose between save it as object or array. is there any different between them when we save them in database ? which one is faster or maintainable or other pro and cons

thanks

+2  A: 

You cannot save an object nor an array in the database.
Just make this method to fetch scalar values from the database and then organize it in the fashion you like.

Col. Shrapnel
Why not? Just use the serialize() and unserialze() methods!
turbod
@turbod serialized data is not an object anyway. it's a string. You still cannot store an object in the database, but only a string.
Col. Shrapnel
@Col. Shrapnel yes, that what i want to do : serializing things
justjoe
@justjoe what's your problem then? there is no difference for the database, what string to keep.
Col. Shrapnel
@Col. Shrapnel i think about which form the best solution. Right now i just save and retrieve it in form of an multiple array. i want to be sure the decision is correct in long term
justjoe
@justjoe there are no difference what to store in the database. I hope you understand it at last.
Col. Shrapnel
@Col. Shrapnel i hope so and as soon as possible ;D
justjoe
+1  A: 

Save the settings as strings (table: id, key, value). Then retrieve as objects (you don't have to worry if the key exists) or arrays.

takeshin
+1  A: 

One drawback of saving as an Object is that you won't be able to perform select queries easily on database directly. Directly here I mean manual queries execution on database. Sometimes manual query execution requires to perform some cross checks on the data or may be for reporting purpose (in your case reporting may not make sense).

Amit Goyal