Adding Tables automatically

Permalink
Hello

I ws wondeirn gif you could help I ahev bought the table add-on and I need to be able to create a table every time a page is created what function do I use to create a table?

Thakn you

novelnova
View Replies:
smartwebprojects replied on at Permalink Reply
smartwebprojects
There is no specific API function to create a table, but you can take a look into /packages/swp_tables/controllers/dashboard/swp_tables/tables.php to see how a table is created in the 'add_table' method:

public function add_table($params = false) {
      if ($this->isPost()) {
         $db = Loader::db();
         $input_params = array(array(
            "tableName" => $this->post('tableName'),
            "tableNote" => $this->post('tableNote'),
            "orderBy" => intval($this->post('orderBy')),
         ));
         $query = "insert into swpTablesTables set tableName=?, tableNote=?, orderBy=?";
         $db->Execute($query, $input_params);
         $tableID = $db->Insert_ID();
         $this->redirect('/dashboard/swp_tables/tables', 'view', 'new_table_added');
      }
   }


In the same file you can also look through the code of 'edit_structure' and 'edit_data' methods, the first one contains the code to add new columns to a table, and the 'edit_data' method has the code to add new data row.