Deleting a specific row in SQL after dynamcic timeframe - PHP, MYSQL [closed] - php

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 7 years ago.
Improve this question
Hey so i need a way to remove a row that is connected to a user after a dynamic time. Eg: Insert that your doing something for 15 minutes, after that 15 minutes i want to delete that row automatically.
There will be lots of rows (users doing stuff) in the database and i need them to all be removed after a custom time for each that is set by the user.
How would i go about this!
Thanks in advannce

You will need 2 things.
a self_destruct_at or equivalent field that is a datetime. That will be set on creating the record.
a worker process to go through ever X minutes (probably 1) and delete the comments that are older than the current time and the created_at + self_destruct_at time

Related

Online voting system in php [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 4 years ago.
Improve this question
My project is online voting system in php, requirements is that one user votes, So he will be able to vote only then after 4 years.
Sessions gonna work ?
No. Sessions only last as long as the browser remains open.
A better idea would be to post the data to a database with a timestamp. Then, when the user tries to vote again, the most recent vote timestamp by that user is drawn from the database.
If the most recent vote timestamp is > 4 years old, you can then allow the user to post again.

How to update day points everyday using php mysql [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 4 years ago.
Improve this question
I am having this project to update the data everyday and I just want it to update like realtime date everyday without opening the website like trigger or some timer in my database.
For example there like points system for bronze account there would be 1 points everyday how can I do that in php mysql thank you for the help
ill just find out the answer to my problem ill just use the MYSQL Event to update the points every day and let the date update everyday .

PHP: Preventing users from getting the same incremented ID [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 7 years ago.
Improve this question
I'm building a php web app that requires to create an invoice, where its ID must be incremented (e.g: 15235, 15236, 15237,...etc). It all works fine with 1 user creating the invoice. The the issue arise when there are more than 1 users hitting the create button at the same time. Supposedly the next incremented ID is 15230, and having 3 users hitting the create button the same time, the app will return 15232 to all 3 users.
FYI, I store the last used ID in a database and increment it when users create an invoice.
Does anyone has any solution? Your suggestion is much appreciated.
Simply use built-in mechanics and define ID field as AUTO_INCREMENT.
You can read more about that here.
After that just skip ID in your INSERT queries and database will take care about that for you.

Automatic increment a field in mysql [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 7 years ago.
Improve this question
I' building up a browsergame. I was wondering what is the best way to build up the "money" system. i no need anything "fast". I mean, the cash cuold be updated every day \ week. Is that possible doing it automatically? Like at 00.00 of every sunday it update automatically? Of course i need to update it every time someone buy something so it shuold be auto incrementing but still modificable with php query system!
Thanks a lot!
table wallets: id, user_id, amount
UPDATE wallets SET amount = amount+10
So you can call this query every week and it will increment all wallets by 10.
http://sqlfiddle.com/#!9/99dfe/1

PHP - Update database every 15 mins [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 9 years ago.
Improve this question
I am trying to set up a database field with a number in it, every 15 that number would increase by, say 5... I was wondering if anyone can give me any insight into how to set this up, or documentation that will lead me in the right direction... I would provide some code but I fear i am already going in the wrong direction and it would just hinder this feed..
I know the logic will go something like this
PHP Script that will generate a number and add to current total
Connect to database
Update Number
disconnect from database
use cronjob to execute script every 15 mins
That is one way of doing it. Assuming it is mySQL, you can also create an event.
Edit: Adding the example:
CREATE EVENT myevent
ON SCHEDULE AT CURRENT_TIMESTAMP + INTERVAL 15 MINUTE
DO
UPDATE myschema.mytable SET mycol = mycol + 1;

Categories