Where to save a single value on server

If you have a DB set up, I'd use it.

That's what DB's are for, persisting changeable data.. otherwise you are basically writing your own separate DB system for the sake of one setting, which would be uberkill in my eyes!

There is value in consistency and flexibility.. what if I suddenly need to store an expected return time? How do I do this in a text-file, how do I differentiate the column? How do I manipulate the data? MySQL already answers all these questions for you.

As a team member, I'd expect most of my dev colleagues (and new hires) to know how to use MySQL.. I wouldn't want them to have to work with, extend or debug a separate bespoke file persistence system that I had tacked on.

If you are worried about having lots of one row tables dotted about, you could use a single table for miscellaneous singular config variables which need updating regularly.

We have a table like this:

Table: `setting` 
Columns: `key_string` VARCHAR, `value` VARCHAR

And could store your variable as

['key_string' => 'telephone_service_available', 'value' => '1']

I know it seems like overkill to use a small database table for this.

If your application already uses a database, this is by far the best way to proceed. Your database technology has all kinds of support for storing data so it doesn't get lost. But, don't stand up a database and organize your application to use it just for this one data point; a file will be easier in that case.

(WordPress does something similar; it uses a table called wp_options containing a lot of one-off settings values.)

I suggest your table contain two columns (or maybe more), agent_id and available. Then, if you happen to add another person taking telephone calls, your app will be ready to handle that growth. Your current person can have agent_id = 0.

Tags:

Mysql

Php

Server