I have an old table with thousands of posts. Each post have 0-4 link to pictures, about a product. Now I have to use the data in the old table to crate a new, and to move the pictures into different folders. I also have to create thumbnails for every picture.
This task sound me a big job, with a long runtime. Should I write the code for this only in a single .php file, than just let the server to run it, or there is a special technique for this. All in all how can you work with huge tables and tons of pics via php?
Finally I found out how can I solve it so I share the technique I used.
I wrote a code in PHP that manipulates the database, moves the pictures and creates thumbnails for each post (row in the table). Because of the big amount of posts, I wasn’t able to run this correctly because the
max_execution_timewas set to30and of course the runtime was much bigger, so I divided the task to 30 sec parts. I added a new column (where I store if a row has processed) to the table, and always only selected the rows that weren’t processed before. After all, I created a cron job that runs this PHP file in every minute.I could also used the command line, because there aren’t time limit, but I didn’t have SSH access.