I am now writing some query’s for a cronjob.
The query’s need to create a table like an existing table.
Only it has to add the date of the day after (without separations) to the tablename.
I have come up with this solution:
Code to date of tomorrow:
$date = date ('dmY');
$date = strtotime(date("dmY", strtotime($date)) . " +1 day");
The query:
$queryvc = "CREATE TABLE vervanger$date LIKE vervanger;
INSERT vervanger$date SELECT * FROM vervanger";
When I echo this in PHP it gives the result I want, but the query doesn’t execute. And I think it is because of the fact that I do not ‘cut out’ the $date from the query which is normally a must. Does anyone have a solution to this?
The query will be run once a week with a cronjob, but in the cronjob all tables with dates more than few months back will also be deleted. That way the database will not grow TOO big.
base if you dont have set DATE_ADD (adding timestamp for each row).
table to the archive table.
Creating tables with timestamp names is bad choice..