Is there a table can only record a row of information Ah, such as corporate Web site, website introduction, set information, address, and other information, only need a line can, so how to build a table record it?
Reply content:
Is there a table can only record a row of information Ah, such as corporate Web site, website introduction, set information, address, and other information, only need a line can, so how to build a table record it?
If you ask, we will encounter this scene, with the file word read and write more trouble, the file is more suitable for some fixed write dead configuration,
K-v words, with Memcache,redis memory database, but also worry about data loss. So MySQL is a relationship-based type, so
We can use the database skillfully and get a small k-v database.
Create a table with a key,value field that is designed to hold some information that may be read and written.
In fact, it is easy to get a simple type of k-v database.
A record represents a configuration.
For example, the configuration contains website information, administrator interface style, expiration time and so on.
id dicKey value1 web_info "企业网站,网站介绍,设置信息,地址,等信息"2 admin_style "green"3 expire 360
Next, as long as you encapsulate the logic
Can do get('key')
it completely,set('key')
You can look at WordPress, a variety of CNS design styles, there is a System Setup table, name and Value fields,
Add a row settings,vlue for the serialized result of these key values, so that there is only one row
In this case, it doesn't use the database. Just need to write a configuration file in JSON or XML.