Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can I Store a Single Variable (not in a Table) In PHP/MySQL Database

Tags:

php

mysql

I have a database which stores a large amount of data in tables. This works fine, but I have a few individual variables that I need to store which are not "repeatable" in the sense that there will be no need for additional rows to store more copies of them.

I could just create a single table storing these miscellaneous variables and leave only a single row in that table, but that doesn't seem like the most efficient or cleanest option.

Is there a better approach (or ideally a way to store a single variable in MySQL)?

like image 494
Michael.Lumley Avatar asked Dec 15 '13 11:12

Michael.Lumley


1 Answers

Just create a table e.g. called 'variables' with two fields 'name' and 'value'. Store your variables in this table, and there you go.

like image 168
rawdog Avatar answered Oct 13 '22 04:10

rawdog