php - WHMCS, how can I run code only once
I have create some functions that are hooked on several WHMCS hooks. Some of my functions are require to be a new table in database that I create for my functionality.
What I like to do is to programmatically create the table into Database, but run the code that generate the table only one time and never run that code again.
Is there any way or a good idea on how to do that ?
Answer
Solution:
In my WHMCS module that I have created, I use the following logic:
I then use the following to create the database:
I have many of these which I then run through a loop:
I then add each column to the table:
which I also run through a loop - this allows me to add new columns/tables and re-run the installation script and add any columns/tables that don't already exist.