Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6939307
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T12:36:21+00:00 2026-05-27T12:36:21+00:00

I have create some functions that are hooked on several WHMCS hooks. Some of

  • 0

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 ?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T12:36:22+00:00Added an answer on May 27, 2026 at 12:36 pm

    In my WHMCS module that I have created, I use the following logic:

    if(!mysql_num_rows(mysql_query("SHOW TABLES LIKE 'modulename_%'"))) {
    
        // there are no tables in the database for our module so we need to create them
    
    }
    

    I then use the following to create the database:

    $createTable[] = 'CREATE TABLE IF NOT EXISTS `modulename_table` ( `id` int(11) NOT NULL auto_increment, PRIMARY KEY  (`id`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1;';
    

    I have many of these which I then run through a loop:

    $createTableCount = 0;
    for($s=0,$e=count($createTable); $s<$e; $s++){
           $query = mysql_query($createTable[$s]);
           if($query)
                $createTableCount++;
    }
    

    I then add each column to the table:

    $alterTable[] = 'ALTER TABLE `modulename_table` ADD `something` int(11) NOT NULL;';
    

    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.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I failed to create a mini-library with some useful functions that I have found
So I have Html like this http://trac.edgewall.org/wiki/RecentChanges (I want to create some Flash Track
I have several web services I need to create for them some testing mechanism
I have some functions that can be grouped together, but don't belong to some
I have have a function in wrote in C++ that calls some functions in
I have several functions that may or may not need to be repeated a
I have some PowerShell helper functions in a file. I'd like to make them
I have a multi-thread C# application that uses some recursive functions in a dll.
I have some Matlab functions that I have to translate in C but I
I have a bunch of functions that map to and from some codes defined

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.