Mysql database - What would you do?

Hello.

I am working on an theme editor, wich allows theme developers to make an array with the functions for there website, like wich elements can change colors.

Okay, so my problem is that, how would you save the theme functions? I was thinking on three ways:

  1. Save the array in database serialize
  2. Save the array as json file in theme folder
  3. save every function in a database column in theme_functions

I know that this issent about Phalcon, but I hope someone has a great answer for this

I'd opt for either #1 or #3.

#2 could become a pain in the arse when you have to make sure it's in sync with the parent data (db relations ftw!)

If you're only reading these values, then #1 is fine.

If you want to make searches against this data (like has that particular function been defined for that theme), #3 is better.

Okay,

So you are saying that if i have data theme_functions in one column as serilize ( It can be a pretty long text ) and one column with theme_function_values that is also serialized, it's the best way?

When i fetch the theme functions i run threw a foreach and insert the value that matches the key, is this bad?

Thanks for your reply, and sorry for my bad english.

As @Lajos said, #3 if search will be needed, #1 only if reading and you are lazy :)

If you have enough time, you can go with #3 even tho you will only need reading, it will make your life easier if things change in future. From personal experience I have regreted multiple times using serialize, but its "easily" fixable :)

Okay, but when i fetches the data wich one is faster?

The theme functions is not going to be changed at all - But the values does

But I have 30 theme functions, and i need to fetch 30 rows from the database, woulden the load time be bad?

I have quite a few items from a static db library that i load into memcached for retreival.

Also you can save JSON into a field now with MySql, so you might not need the file version or the serialized data.