imgrooot Posted April 8, 2017 Share Posted April 8, 2017 I currently have a php code at the top of the page that would automatically delete a user from the database if a certain condition isn't met before 24 hours. This code is processed no matter where you are on the site. I have two questions. 1. Will this be an issue if the database has thousands of users? 2. Is there a better way to do this? Quote Link to comment Share on other sites More sharing options...
requinix Posted April 8, 2017 Share Posted April 8, 2017 1. Maybe? Technical details and a precise description would make it easier to answer. 2. Maybe? Technical details and a precise description would make it easier to answer. Oh. Advice: don't delete stuff. I'd give you a better alternative but technical details and-- well, you know. Quote Link to comment Share on other sites More sharing options...
imgrooot Posted April 8, 2017 Author Share Posted April 8, 2017 1. Maybe? Technical details and a precise description would make it easier to answer. 2. Maybe? Technical details and a precise description would make it easier to answer. Oh. Advice: don't delete stuff. I'd give you a better alternative but technical details and-- well, you know. What technical details are you looking for? I do not require you to give me a code example. I am simply looking for alternative methods. Word description should suffice. Quote Link to comment Share on other sites More sharing options...
requinix Posted April 8, 2017 Share Posted April 8, 2017 Looking for more than just "a user" (who? did they sign up? are they in a pending state?) "the database" (list of users? list of pending users? list of users with temporary access?) "certain condition" (pending state? failed subscription renewal? didn't follow instructions?) "site" (what kind of site?) "has thousands of users" (logical users stored in the database? actual users who connect? concurrent?) and "better way to do this" (what is the purpose? does it meet your needs right now? asking about best practices?) Believe it or not, in the software industry, a question can have multiple correct answers that depend on circumstances. And I, for one, am not going to rack my brain for all the answers I can think of only to discover none of them are actually relevant to you. Or maybe you want the tldr version? Quote Link to comment Share on other sites More sharing options...
Jacques1 Posted April 8, 2017 Share Posted April 8, 2017 The whole approach sounds odd. The standard workflow for user management looks more like this: When the user account is initially created, you store the timestamp and set an “activated” flag to “false”. Within a certain timeframe (in your case 24 hours), the user can activate their account, i. e. set the flag to “true”. As long as the account isn't activated, the user only has limited permissions (or no permissions at all, whatever is appropriate). If you absolutely must clean up dead accounts, you can set up a cron job which does this regularly. But as requinix already said, deleting data is rarely a good idea. Nowadays, a few extra bytes of MySQL records really don't hurt your HDD/SSD, and you never know when that data might be useful (debugging, statistics, ...). Get rid of sensitive information, though. Quote Link to comment Share on other sites More sharing options...
Solution imgrooot Posted April 8, 2017 Author Solution Share Posted April 8, 2017 The whole approach sounds odd. The standard workflow for user management looks more like this: When the user account is initially created, you store the timestamp and set an “activated” flag to “false”. Within a certain timeframe (in your case 24 hours), the user can activate their account, i. e. set the flag to “true”. As long as the account isn't activated, the user only has limited permissions (or no permissions at all, whatever is appropriate). If you absolutely must clean up dead accounts, you can set up a cron job which does this regularly. But as requinix already said, deleting data is rarely a good idea. Nowadays, a few extra bytes of MySQL records really don't hurt your HDD/SSD, and you never know when that data might be useful (debugging, statistics, ...). Get rid of sensitive information, though. I understand the normal process of registering user and sending them an email link to activate their account. Unfortunately my process has to be little different. The user is activated with the signup. So no activation email link is required. They have 24 hours to make a payment or else their account is deleted. I'll take your advice to keep their essential data(user's primary info) and delete all other data. I have never used cron job before but it seems to be exactly what I am looking for. Quote Link to comment Share on other sites More sharing options...
imgrooot Posted April 8, 2017 Author Share Posted April 8, 2017 Looking for more than just "a user" (who? did they sign up? are they in a pending state?) "the database" (list of users? list of pending users? list of users with temporary access?) "certain condition" (pending state? failed subscription renewal? didn't follow instructions?) "site" (what kind of site?) "has thousands of users" (logical users stored in the database? actual users who connect? concurrent?) and "better way to do this" (what is the purpose? does it meet your needs right now? asking about best practices?) Believe it or not, in the software industry, a question can have multiple correct answers that depend on circumstances. And I, for one, am not going to rack my brain for all the answers I can think of only to discover none of them are actually relevant to you. Or maybe you want the tldr version? I understand. I am good now. "Jacques1" has answered my question. Cron job is what I'm looking for. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.