开发者

design decision between array or object save in database

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 开发者_StackOverflowas 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


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.


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.


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).

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜