There are numbers like: 1111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 (168 characters).
These numbers are a set of 168-point configurations, in the form of
What is the best way to store it so that it does not take up space and quickly read it and write it to the database?
In what type of fields is it better to store them?
I will correct the problem: a set of 168 digits is the hourly settings for every day. That is, 7×24 = 168. It is required to write this config bit by bit in the PHP + MySQL link into the list -> (field) settings table.
<?php $d1='111111111111111111000000'; $d2='111111000000111111111111'; $d3='111111111111111111111111'; $d4='111001111111111100111111'; $d5='111111111111111111111111'; $d6='110111111110111111111111'; $d7='000000011111111111111111'; $settings=$d1.$d2.$d3.$d4.$d5.$d6.$d7; $con=mysqli_connect("localhost","db_user","db_password","db"); mysqli_query($con,"INSERT INTO list (settings) VALUES ($settings)"); mysqli_close($con); ?>
Now the database structure is as follows:
`settings` tinyblob NOT NULL,
Takes up this case, respectively [BLOB – 168 Bytes]
I would like to fit into 168 bits (+ -), since there will be many such configs.
How do I implement this in PHP?
If this is really a set of settings, then it is better to store it in a separate table, in the format "name – on / off flag".
The full set of settings is read out in the same way with one request, and it will be much easier to work with it at times. Especially if at some point you have to delete setting # 40.
For an updated version of the question – if these are hourly settings – they should be stored in a table like
Номер конфига | День недели | Час | On/Off
And you don't have to work with bits at all. You can safely download the entire config, and in one call find out the setting for the right hour of the right day.
If you are worried about the occupied volume – in vain. This is about a kilobyte per config. Approximately $ 0.00000004 at current storage prices.