I have a MariaDB database for our Open Journal Server. It has a table called "notification_subscription_settings" that contains one line per each type of notification that a user selected.
On the screenshot below, a user put a checkmark in "Enable these types of notification" under "New announcement" and under "An issue has been published", but no checkmark in "Do not send me an email for these types of notifications." This way, they will not only see pop-ups when looking at the journal online BUT ALSO will also automatically receive this notification in email. That is a default behavior of the site that I want to change, so users only get pop-ups, BUT NO emails, unless they go to their profile and select that option themselves.
I want to insert two entries per those users who have not touched their notification settings, placing a checkmark in "Do not send me an email for these types of notifications." It will add two rows (one with a "8" and one with a "268435477") to the database so it looks like this:
setting_id, setting_name, setting_value, user_id, context, setting_type
(469, 'blocked_emailed_notification', '8', 3747, 8, 'int'),
(470, 'blocked_emailed_notification', '268435477', 3747, 8, 'int');
The setting_id needs to start from 471 and get increased by 1 with each new row. The user_id needs to be taken from a list of a few hundred users that I have ready in a text file.
How can I do it in PHPMyAdmin?
id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra | |
---|---|---|---|---|---|---|---|---|---|---|
1 | SIMPLE | notification_subscription_settings | index | NULL | PRIMARY | 8 | NULL | 412 |
"setting_id";"setting_name";"setting_value";"user_id";"context";"setting_type"
"446";"blocked_emailed_notification";"16777217";"3747";"8";"int"
"447";"blocked_emailed_notification";"16777247";"3747";"8";"int"
"448";"blocked_emailed_notification";"16777218";"3747";"8";"int"
"449";"blocked_emailed_notification";"16777219";"3747";"8";"int"
"450";"blocked_emailed_notification";"16777249";"3747";"8";"int"
"451";"blocked_emailed_notification";"16777250";"3747";"8";"int"
"452";"blocked_emailed_notification";"8";"3747";"8";"int"
"453";"blocked_emailed_notification";"16777258";"3747";"8";"int"
"454";"blocked_emailed_notification";"268435477";"3747";"8";"int"
"463";"blocked_notification";"16777217";"3800";"8";"int"
"464";"blocked_notification";"16777247";"3800";"8";"int"
"465";"blocked_notification";"16777218";"3800";"8";"int"
"466";"blocked_notification";"16777219";"3800";"8";"int"
"467";"blocked_notification";"16777249";"3800";"8";"int"
"468";"blocked_notification";"16777250";"3800";"8";"int"
"469";"blocked_notification";"8";"3800";"8";"int"
"470";"blocked_notification";"16777258";"3800";"8";"int"
"471";"blocked_notification";"268435477";"3800";"8";"int"
"""478"",""blocked_emailed_notification"",""8"",""97"",""8"",""int"""
Change it to:"blocked_emailed_notification","8","97","8","int"
Or even better:blocked_emailed_notification,8,97,8,int
blocked_emailed_notification,8,44,8,int
blocked_emailed_notification,268435477,44,8,int
blocked_emailed_notification,8,60,8,int
blocked_emailed_notification,268435477,60,8,int
"setting_id";"setting_name";"setting_value";"user_id";"context";"setting_type"
"470";"blocked_notification";"16777258";"3800";"8";"int"
"471";"blocked_notification";"268435477";"3800";"8";"int"
"472";"8";"44";"8";"0";
"473";"268435477";"44";"8";"0";
"474";"8";"60";"8";"0";
"475";"268435477";"60";"8";"0";
blocked_emailed_notification,8,44,8,int
and the command says that fields are terminated by ','LOAD DATA INFILE 'rows_to_batch_load.csv' INTO TABLE notification_subscription_settings FIELDS TERMINATED BY ',' LINES TERMINATED BY '\n'
ALTER TABLE notification_subscription_settings AUTO_INCREMENT = 472
As far bulk-loading goes, if your text file is already in a CSV-type format that matches the table structure, then you can either upload the file to the server and use the LOAD DATA INFILE query to import the data into the table or you can use the phpMyAdmin import feature which is just a wrapper around the same process.
LOAD DATA INFILE - MariaDB Knowledge Base
There are a bunch of other possibilities (e.g. an INSERT query with multiple records, or a SELECT/INSERT combo query,converting the text file to a bunch of queries and just running it as a .sql file though that's the slowest method). So it kind of depends on what your text file looks like, how many records you have, etc... But since you said you want to do it in phpMyAdmin, its import feature is probably what you're looking for.