| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657 |
- <?php
- namespace ThurData\Servers\KerioEmail\Core\Helper;
- use ThurData\Servers\KerioEmail\Core\FileReader\Reader;
- use ThurData\Servers\KerioEmail\Core\ServiceLocator;
- use WHMCS\Database\Capsule;
- /**
- * Autometes some of database queries
- *
- * @author
- */
- class ConfigOptionsHelper
- {
-
- /**
- * Helper to perform Configurable Options queries for module
- *
- * @param int $productID
- * @param string $optionName
- * @return Object
- */
- public function getConfigurableOption(int $productID, string $optionName) {
- $configOption = Capsule::table('tblproductconfigoptions')
- ->join('tblhostingconfigoptions', 'tblproductconfigoptions.id', '=', 'tblhostingconfigoptions.configid')
- ->where('tblhostingconfigoptions.relid', '=', $productID)
- ->where('tblproductconfigoptions.optionname', 'like', $optionName.'%')
- ->select('*')
- ->get();
- return $configOption->pull(0);
- }
- /**
- * Helper to perform Configurable Options queries for module
- *
- * @param int $optionID
- * @param array $optionValues
- * @return bool
- */
- public function updateConfigurableOption(int $optionID, array $optionValues) {
- try {
- $updateOption = Capsule::table('tblhostingconfigoptions')
- ->where('id', $optionID)
- ->update($optionValues);
- } catch (\Exception $e) {
- logModuleCall(
- 'kerioEmail',
- __FUNCTION__,
- $updateOption,
- 'Error: could not update option ' . $optionID .' in database.',
- $e->getMessage()
- );
- return false;
- }
- return true;
- }
- }
|