Jump to content

Recommended Posts

I fully admit there's a lot out there that I don't know I don't know as for PHP advancements. So I'm looking for some leads on some simple data storage.

 

My script will apply a configuration to an interface. I want the ability to save those configs as templates that can later be easily applied. So I'm looking to store a name and a few parameters, most numeric.

 

I'll need to manage name conflicts and have the ability to delete templates. I probably won't even have an update functionality and just have the users delete and add new when they need to make changes.

 

The API will be expected to return a list of templates that JavaScript will use to populate a drop-down. Selecting a value will fill a form with values to be applied. There'll be a list of existing templates with delete buttons. Deleting one will need to update the drop-down.

 

Based on what I do know, I'd handle this with a flat file and delimited values. API would read the file, create an array and send that as a json encoded response. GET, POST (new template) and DELETE requests would act accordingly.

 

I don't see the need for a database, but I'm thinking of MySQL when I say that.

 

So what are your thoughts? What don't I know that I should?

 

Thanks.

What is the nature of the config/template data? I mean, is it like a config file you'd find in Linux, or is it a set of key/value pairs, or what? As for what's inside each config, how do you know what that's supposed to be like? For example, how do you know what config "options" are valid, and what sorts of values (string, int, etc.) each one uses?

A name for the template and a few numeric values for delay, loss and rate.

 

Name, 500, "ms", 100, "ms", 5, 12, "mbit"

 

If I apply a template, I'll need all of those values. Some values are optional, though, so with a file, I'd have to list "null" or zero values.

 

I'll never need to do any queries looking for certain values of parameters. Just all or nothing view, apply, delete options through the API.

 

Does that help?

If I were to write them as an array, it'd be

 

$template["name"] = {"delay"=>500, "delay_unit"=>"ms", "loss"=>5}

 

Template may have one parameter or 10.

 

Forgive the syntax, as that's probably wrong. Hopefully you get the idea.

Edited by Sepodati

Do all configs have those same "keys" (delay, loss, rate, etc.) and the only difference between them is whether a value is optional and/or what the default is?

 

In other words, could all possible templates and configs be represented in a single database table?

name | delay | delay_unit | loss | abc  | def
-----+-------+------------+------+------+-----
 Foo |   500 |         ms |    5 |   12 | mbit
Name |   500 |         ms |    5 | NULL | NULL
If so then a database table is the way to go. If not then it still might be but I'm not clear on what the differences can be.
This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.