/** * Initialize the Table * * @param array $params Parameters from the {form_table} tag */ public function init($params) { parent::init($params); // Build an HostingPurchase filter $where = isset($this->accountID) ? sprintf("accountid='%d'", $this->accountID) : null; $where = isset($this->serverID) ? sprintf("serverid='%d'", $this->serverID) : $where; // Load the HostingPurchase Table try { // Build the table $purchases = load_array_HostingServicePurchaseDBO($where); foreach ($purchases as $dbo) { // Put the row into the table $this->data[] = array("id" => $dbo->getID(), "title" => $dbo->getTitle(), "term" => $dbo->getTerm(), "serverid" => $dbo->getServerID(), "hostname" => $dbo->getHostName(), "recurringprice" => $dbo->getRecurringPrice(), "onetimeprice" => $dbo->getOnetimePrice(), "date" => $dbo->getDate(), "accountname" => $dbo->getAccountName(), "nextbillingdate" => $dbo->getNextBillingDate(), "domainname" => $dbo->getDomainName()); } } catch (DBNoRowsFoundException $e) { } }
/** * Get Hosting Service Purchases * * Returns an array of HostingServicePurchaseDBO's assigned to this server * * @return array Array of HostingServicePurchaseDBO's */ function getPurchases() { try { return load_array_HostingServicePurchaseDBO("serverid=" . $this->getID()); } catch (DBNoRowsFoundException $e) { return array(); } }
/** * Get Hosting Service Purchases for this Account * * return array Array of HostingServicePurchaseDBO's for this account */ function getHostingServices() { try { return load_array_HostingServicePurchaseDBO("accountid=" . intval($this->getID())); } catch (DBNoRowsFoundException $e) { return array(); } }
/** * Delete HostingServiceDBO from database * * @param HostingServiceDBO &$dbo HostingServiceDBO to delete * @return boolean True on success */ function delete_HostingServiceDBO(&$dbo) { $DB = DBConnection::getDBConnection(); $id = $dbo->getID(); try { load_array_HostingServicePurchaseDBO("hostingserviceid=" . $id); // Can not delete service if any purchases exist throw new DBException("[PURCHASES_EXIST]"); } catch (DBNoRowsFoundException $e) { } // Build DELETE query $sql = $DB->build_delete_sql("hostingservice", "id = " . $dbo->getID()); // Run query if (!mysql_query($sql, $DB->handle())) { throw new DBException(mysql_error($DB->handle())); } }