Hi,
I would like to request an assistant.
It seems that i encounter error as follows :
--------------------------
----------
---------
A PHP Error was encountered
Severity: Notice
Message: Undefined property: stdClass::$packageid
Filename: models/home_model.php
Line Number: 239
--------------------------
----------
----------
I believe it was due to the following function :
function get_package_id_where($conf
ig_id)
I have ensure that $config_id carry variable as i have print it and it shows correctly.
Can anybody spot the error in the code ?
Can help to adjust it ? for me to try ?
The following is the code.
function get_optionname_awbs($id) {
$awbs = $this->load->database('default', TRUE);
$q = $awbs->query('SELECT type FROM hosting_addons WHERE id = ' . $id . '');
if ($q->num_rows() > 0) {
foreach ($q->result() as $row) {
return $row->type;
}
} else
return 0;
}
function awbs_group_configoptions_name($awbs_addon_type) {
$awbs = $this->load->database('default', TRUE);
$q = $awbs->query('SELECT description FROM hosting_addon_types WHERE type = ' . $awbs_addon_type . '');
if ($q->num_rows() > 0) {
foreach ($q->result() as $row) {
return $row->description;
}
} else
return 0;
}
function get_package_id_where($config_id) {
$whmcs = $this->load->database('whmcs', TRUE);
$q = $whmcs->query('SELECT awbsid FROM tblhosting WHERE id = ' . $config_id . '');
if ($q->num_rows() > 0) {
foreach ($q->result() as $row) {
return $row->packageid; // <<< This is where the line shows error .
}
} else return 0;
}
function get_group_id_where($package_id) {
$whmcs = $this->load->database('whmcs', TRUE);
$q = $whmcs->query('SELECT gid FROM tblproductconfiglinks WHERE pid = ' . $package_id . '');
if ($q->num_rows() > 0) {
foreach ($q->result() as $row) {
return $row->gid;
}
} else return 0;
}
function get_tblproductconfigoptions_id($group_id, $optionname) {
$whmcs = $this->load->database('whmcs', TRUE);
$q = $whmcs->query('SELECT id FROM tblproductconfigoptions WHERE gid = ' . $group_id . ' AND optionname = "' . $optionname . '"');
if ($q->num_rows() > 0) {
foreach ($q->result() as $row) {
return $row->id;
}
} else return 0;
}
function get_id_from_tblproductconfigoptionssub($group_config_id, $awbs_addon_name) {
$whmcs = $this->load->database('whmcs', TRUE);
$q = $whmcs->query('SELECT id FROM tblproductconfigoptionssub WHERE configid = ' . $group_config_id . ' AND optionname = "' . $awbs_addon_name . '"');
if ($q->num_rows() > 0) {
foreach ($q->result() as $row) {
return $row->id;
}
} else return 0;
}
foreach ($addonlist as $key => $value) {
$if_dedicated = strpos($value["parent_id"], 'D');
//$str_replace_package_id = str_replace('D', '', $value["parent_id"]);
if ($if_dedicated !== false) {
$str_replace_dedicated = str_replace('D', '', $value["parent_id"]);
$tblhostingconfigoptions[$key]['relid'] = $str_replace_dedicated;
$tblhostingconfigoptions[$key]['qty'] = $value["qty"];
//name of the addon awbs
$awbs_addon_name = $value["name"];
//type addon awbs
$awbs_addon_type = $this->get_optionname_awbs($value["itemid"]);
//group name configoptions
$awbs_group_configoptions_name = $this->awbs_group_configoptions_name($awbs_addon_type);
//package which uses the hosting client
$package_id = $this->get_package_id_where($tblhostingconfigoptions[$key]['relid']);
//group configoptions
$group_id = $this->get_group_id_where($package_id);
$group_config_id = $this->get_tblproductconfigoptions_id($group_id, $awbs_group_configoptions_name);
$tblhostingconfigoptions[$key]['configid'] = $group_config_id;
$optionid = $this->get_id_from_tblproductconfigoptionssub($group_config_id, $awbs_addon_name);
$tblhostingconfigoptions[$key]['optionid'] = $optionid;
$whmcs->insert('tblhostingconfigoptions', $tblhostingconfigoptions[$key]);
}
}
Open in new window
Thank you.