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;
Related
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 .
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
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.
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
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 8 years ago.
Improve this question
We have a database table with created datetime and status flag. We would like to update the status flag to the next status if the created date time has elapsed by 30 minutes without any user intervention. How can we achieve this in php.
Create a php file that does this status change in the database and program to execute it every 30 minutes with cron (Linux) or Task Scheduler (Windows).
You have to think carefully about how you design and use your database. Sometimes things are made overly complicated when they don't need to. For instance, in this case you could use a 'datetime' in your table indicating the start time. Any PHP script can now check whether or not the start time started 30 minutes ago, only when this information is actually needed. No need for a flag, cron jobs, etc.