Answer the question
In order to leave comments, you need to log in
Have I written the stored procedure code correctly?
DELIMITER //
BEGIN
SET @email = (SELECT email FROM accounts WHERE id = uid LIMIT 1);
SET @rdt = (SELECT regDT FROM accounts WHERE id = uid LIMIT 1);
SET @now = NOW();
IF @email IS NULL AND @now > DATE_ADD(@rdt, INTERVAL 7 DAY) THEN
UPDATE accounts SET blocked = 1 WHERE id = uid LIMIT 1;
END IF;
END//
CREATE TABLE IF NOT EXISTS `accounts` (
`id` bigint(20) NOT NULL COMMENT 'Идентификатор пользователя',
`login` tinytext NOT NULL COMMENT 'Логин',
`pass` tinytext NOT NULL COMMENT 'Пароль',
`email` tinytext COMMENT 'Почта',
`regDT` datetime NOT NULL COMMENT 'Дата и время регистрации',
`regIP` varchar(15) NOT NULL DEFAULT '0.0.0.0' COMMENT 'Регистрационный IP',
`blocked` tinyint(1) NOT NULL DEFAULT '0' COMMENT 'Заблокирован?'
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Аккаунты';
Answer the question
In order to leave comments, you need to log in
UPDATE `accounts`
SET `blocked` = 1
WHERE `email` IS NULL
AND `regDT` < NOW() - INTERVAL 7 DAY
AND `id` = :uid
Normal storage. but you can try to do an UPDATE with one request
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question