Added the get_affected_rows function to database.php and refactored the order model.