/** * Add Price */ protected function addPrice() { if ($this->post['type'] == "Onetime" && $this->post['termlength'] != 0) { throw new SWUserException("[TERMLENGTH_FOR_ONETIME_MUST_BE_ZERO]"); } if ($this->post['type'] == "Recurring" && $this->post['termlength'] == 0) { throw new SWUserException("[TERMLENGTH_FOR_RECURRING_MUST_NOT_BE_ZERO]"); } $priceDBO = new HostingServicePriceDBO(); $priceDBO->setServiceID($this->get['hservice']->getID()); $priceDBO->setType($this->post['type']); $priceDBO->setTermLength($this->post['termlength']); $priceDBO->setPrice($this->post['price']); $priceDBO->setTaxable($this->post['taxable']); try { $this->get['hservice']->addPrice($priceDBO); add_HostingServicePriceDBO($priceDBO); $this->setMessage(array("type" => "[PRICE_ADDED]")); } catch (DuplicatePriceException $e) { update_HostingServicePriceDBO($priceDBO); $this->setMessage(array("type" => "[PRICE_UPDATED]")); } $this->reload("&sstab=pricing"); }
/** * Load multiple HostingServicePriceDBO's from database * * @param string $filter A WHERE clause * @param string $sortby Field name to sort results by * @param string $sortdir Direction to sort in (ASEC or DESC) * @param int $limit Limit the number of results * @param int $start Record number to start the results at * @return array Array of HostingServiceDBO's */ function load_array_HostingServicePriceDBO($filter = null, $sortby = null, $sortdir = null, $limit = null, $start = null) { $DB = DBConnection::getDBConnection(); // Build query $sql = $DB->build_select_sql("hostingserviceprice", "*", $filter, $sortby, $sortdir, $limit, $start); // Run query if (!($result = @mysql_query($sql, $DB->handle()))) { // Query error throw new DBException(mysql_error($DB->handle())); } if (mysql_num_rows($result) == 0) { // No services found throw new DBNoRowsFoundException(); } // Build an array of HostingServicePriceDBOs from the result set $price_dbo_array = array(); while ($data = mysql_fetch_array($result)) { // Create and initialize a new HostingServiceDBO with the data from the DB $dbo = new HostingServicePriceDBO(); $dbo->load($data); // Add HostingServiceDBO to array $price_dbo_array[] = $dbo; } return $price_dbo_array; }