/**
 * Insert OrderHostingDBO into database
 *
 * @param OrderHostingDBO &$dbo OrderHostingDBO to add to database
 */
function add_OrderHostingDBO(OrderHostingDBO $dbo)
{
    $DB = DBConnection::getDBConnection();
    // Build SQL
    $sql = $DB->build_insert_sql("orderhosting", array("orderid" => intval($dbo->getOrderID()), "orderitemid" => intval($dbo->getOrderItemID()), "serviceid" => $dbo->getServiceID(), "status" => $dbo->getStatus(), "term" => $dbo->getTerm(), "domainname" => $dbo->getDomainName()));
    // Run query
    if (!mysql_query($sql, $DB->handle())) {
        throw new DBException(mysql_error($DB->handle()));
    }
    // Get auto-increment ID
    $id = mysql_insert_id($DB->handle());
    // Validate ID
    if ($id === false) {
        // DB error
        throw new DBException("Could not retrieve ID from previous INSERT!");
    }
    if ($id == 0) {
        // No ID?
        throw new DBException("Previous INSERT did not generate an ID");
    }
    // Store ID in DBO
    $dbo->setID($id);
}