Database schema creation and AdminServicesTabFieldsSave in WHMCS
I want to create a WHMCS custom module and need assistance with
template_AdminServicesTabFieldsSave($params) as specified in the sample
code for http://docs.whmcs.com/Creating_Modules.
In my template_AdminServicesTabFields($params) I have the following code:
function template_AdminServicesTabFields($params) {
$fieldsarray = array(
'Debug Mode' => '<input type="checkbox" name="modulefields[0]">',
);
return $fieldsarray;
}
I want to use the template_AdminServicesTabFieldsSave($params) function to
save the status of 'Debug Mode' to a database.
In light of the above function the database save code will look something
like:
function template_AdminServicesTabFieldsSave($params) {
update_query("mod_customtable",array(
"var1"=>$_POST['modulefields'][0],
),array("serviceid"=>$params['serviceid']));
}
My problem is I don't know what the schema for mod_customtable should look
like nor how to create a MySQL database field that can store the $_POST
value.
In order to create the database I follow this documentation:
http://docs.whmcs.com/Addon_Module_Developer_Docs (I changed
mod_addonexample to mod_customtable)
function demo_activate() {
# Create Custom DB Table
$query = "CREATE TABLE `mod_customtable` (`id` INT( 1 ) NOT NULL
AUTO_INCREMENT ... ";
$result = mysql_query($query);
...
}
So the specific area of MySQL and WHMCS that I need help with is:
update_query("mod_customtable",array(
"var1"=>$_POST['modulefields'][0],
),array("serviceid"=>$params['serviceid']));
What kind of field should I create to store
array(
"var1"=>$_POST['modulefields'][0],
),array("serviceid"=>$params['serviceid'])
I need to store:
Value for Debug Mode
The array / params for service ID
No comments:
Post a Comment