Answer the question
In order to leave comments, you need to log in
How to find a match by email and write data to the database from JSON?
I am trying to add additional functionality for users in dle cms, more precisely, save additional information about the user to the dle cms database, while receiving additional data from JSON from a third-party service.
I want to run a cron script and check the correspondence of email from json with email of users registered on the site dle_users - email.
Sample json data :
[{"id":323,"userId":676,"createdAt":"2019-08-23T13:05:56.830Z","status":"APPROVED","currency":"RUR","paySystem":"visa","paySystemGroup":"creditCard","total":69.00,"ipAddress":"246.227.2.4","OneTimeOffer":false,"ware":{"id":812,"title":"Заголовок.","type":"DIGITAL","userId":728},"income":297.08,"customer":{"id":8832,"fio":"Петрович","email":"[email protected]"}}, {"id":324,"userId":677,"createdAt":"2019-08-23T14:05:56.830Z","status":"APPROVED","currency":"RUR","paySystem":"visa","paySystemGroup":"creditCard","total":69.00,"ipAddress":"246.227.2.4","OneTimeOffer":false,"ware":{"id":813,"title":"Заголовок.","type":"DIGITAL","userId":729},"income":297.08,"customer":{"id":8833,"fio":"Петрович","email":"[email protected]"}}, {"id":325,"userId":678,"createdAt":"2019-08-23T15:05:56.830Z","status":"APPROVED","currency":"RUR","paySystem":"visa","paySystemGroup":"creditCard","total":69.00,"ipAddress":"246.227.2.4","OneTimeOffer":false,"ware":{"id":814,"title":"Заголовок.","type":"DIGITAL","userId":730},"income":297.08,"customer":{"id":8834,"fio":"Петрович","email":"[email protected]"}}]
--
-- Структура таблицы `dle_users`
--
CREATE TABLE `dle_users` (
`email` varchar(50) NOT NULL DEFAULT '',
`password` varchar(255) NOT NULL DEFAULT '',
`name` varchar(40) NOT NULL DEFAULT '',
`user_id` int(11) NOT NULL,
`news_num` mediumint(8) NOT NULL DEFAULT '0',
`comm_num` mediumint(8) NOT NULL DEFAULT '0',
`user_group` smallint(5) NOT NULL DEFAULT '4',
`lastdate` varchar(20) NOT NULL DEFAULT '',
`reg_date` varchar(20) NOT NULL DEFAULT '',
`banned` varchar(5) NOT NULL DEFAULT '',
`allow_mail` tinyint(1) NOT NULL DEFAULT '1',
`info` text NOT NULL,
`signature` text NOT NULL,
`foto` varchar(255) NOT NULL DEFAULT '',
`fullname` varchar(100) NOT NULL DEFAULT '',
`land` varchar(100) NOT NULL DEFAULT '',
`favorites` text NOT NULL,
`pm_all` smallint(5) NOT NULL DEFAULT '0',
`pm_unread` smallint(5) NOT NULL DEFAULT '0',
`time_limit` varchar(20) NOT NULL DEFAULT '',
`xfields` text NOT NULL,
`allowed_ip` varchar(255) NOT NULL DEFAULT '',
`hash` varchar(32) NOT NULL DEFAULT '',
`logged_ip` varchar(46) NOT NULL DEFAULT '',
`restricted` tinyint(1) NOT NULL DEFAULT '0',
`restricted_days` smallint(4) NOT NULL DEFAULT '0',
`restricted_date` varchar(15) NOT NULL DEFAULT '',
`timezone` varchar(100) NOT NULL DEFAULT '',
`news_subscribe` tinyint(1) NOT NULL DEFAULT '0',
`comments_reply_subscribe` tinyint(1) NOT NULL DEFAULT '0',
`twofactor_auth` tinyint(1) NOT NULL DEFAULT '0',
`cat_add` varchar(500) NOT NULL DEFAULT '',
`cat_allow_addnews` varchar(500) NOT NULL DEFAULT ''
) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4;
--
-- Дамп данных таблицы `dle_users`
--
INSERT INTO `dle_users` (`email`, `password`, `name`, `user_id`, `news_num`, `comm_num`, `user_group`, `lastdate`, `reg_date`, `banned`, `allow_mail`, `info`, `signature`, `foto`, `fullname`, `land`, `favorites`, `pm_all`, `pm_unread`, `time_limit`, `xfields`, `allowed_ip`, `hash`, `logged_ip`, `restricted`, `restricted_days`, `restricted_date`, `timezone`, `news_subscribe`, `comments_reply_subscribe`, `twofactor_auth`, `cat_add`, `cat_allow_addnews`) VALUES
('[email protected]', '$2y$10$HizMAqnS70XtPyOAhEOBZunFUr0sTf6BxuhAF.jF5064WmVSiInS2', 'Admin', 1, 5, 2, 1, '1566571668', '1566008190', '', 1, '', '', '', '', '', '', 0, 0, '', '', '', 'a5d5341fa03117f2046f5a0b8f1589d0', '33.212.78.120', 0, 0, '', '', 0, 0, 0, '', '');
--
-- Индексы сохранённых таблиц
--
--
-- Индексы таблицы `dle_users`
--
ALTER TABLE `dle_users`
ADD PRIMARY KEY (`user_id`),
ADD UNIQUE KEY `name` (`name`),
ADD UNIQUE KEY `email` (`email`);
--
-- AUTO_INCREMENT для сохранённых таблиц
--
--
-- AUTO_INCREMENT для таблицы `dle_users`
--
ALTER TABLE `dle_users`
MODIFY `user_id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=2;
COMMIT;
Answer the question
In order to leave comments, you need to log in
one.
I need to write to the database id, ware->id, ware->title, income if a match is found for the email address.- add columns for this data to the dle_users table (with a prefix to distinguish them from other columns, for example paym_id, paym_ware_id, paym_title, paym_income) or create a new payment_info table with the same columns plus user_id as the foreign key on the id from the dle_users table.
Several thousand users can be registered on the site.- several thousand - how much?) Up to 10 thousand? Up to 100 thousand? It matters, it affects the decisions made in point 1. For a large table with active data and frequent writes, it is better not to do alter table.
I want to access Json as often as possible via cron- the smallest unit of time in krone is 1 minute. How often do you need? Sometimes once every half an hour is enough - there will be no extra load, but here the question is about business requirements - what is the relevance of this data.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question