/**
  * Assign Product
  *
  * Create a Product Purchase DBO and add it to the database
  */
 function assign_product()
 {
     // Create new ProductPurchase DBO
     $purchase_dbo = new ProductPurchaseDBO();
     $purchase_dbo->setAccountID($this->get['account']->getID());
     $purchase_dbo->setProductID($this->post['product']->getID());
     $purchase_dbo->setTerm(isset($this->post['term']) ? $this->post['term']->getTermLength() : null);
     $purchase_dbo->setDate(DBConnection::format_datetime($this->post['date']));
     $purchase_dbo->setNote($this->post['note']);
     // Save purchase
     add_ProductPurchaseDBO($purchase_dbo);
     // Success
     $this->setMessage(array("type" => "[PRODUCT_ASSIGNED]"));
     $this->gotoPage("accounts_view_account", null, "action=products&account=" . $this->get['account']->getID());
 }
/**
 * Load multiple ProductPurchaseDBO'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 ProdutPurchaseDBO's
 */
function &load_array_ProductPurchaseDBO($filter = null, $sortby = null, $sortdir = null, $limit = null, $start = null)
{
    $DB = DBConnection::getDBConnection();
    // Build query
    $sql = $DB->build_select_sql("productpurchase", "*", $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 DBOs from the result set
    $dbo_array = array();
    while ($data = mysql_fetch_array($result)) {
        // Create and initialize a new DBO with the data from the DB
        $dbo = new ProductPurchaseDBO();
        $dbo->load($data);
        // Add HostingServiceDBO to array
        $dbo_array[] = $dbo;
    }
    return $dbo_array;
}