コード例 #1
0
     //process search form
     $search_token = trim($_POST['token']);
     //process_search_form();//uses GET from inside the body
     //if processed search token is not empty
     if ($search_token) {
         //query database and modify result set with further queries
         $auction_set = query_select_auction_search($search_token);
         for ($i = 0; $i < sizeof($auction_set); $i++) {
             //enrich with price
             $current_price = get_price($auction_set[$i]['auctionId'], $auction_set[$i]['startingPrice']);
             $auction_set[$i]['currentPrice'] = $current_price;
             //once the current price is known, there is no further need for a
             //startingPrice field on the retrieved associative array
             unset($auction_set[$i]['startingPrice']);
             //enrich with rating
             $feedback_array = query_select_user_rating($auction_set[$i]['seller']);
             $auction_set[$i]['stars'] = $feedback_array['stars'];
             $auction_set[$i]['no_of_ratings'] = $feedback_array['occurrences'];
         }
     }
 } else {
     $auction_set = $_POST['auctionSet'];
 }
 $auction_set = process_filter_form($auction_set, $_POST['bottom'], $_POST['top'], $_POST['rating'], $_POST['category']);
 //begin constructing auction set display table, id value used by
 //jQuery to replace construct with ajax request response
 //begin constructing table
 $output = "\n              <table class=\"search-page-table table-striped\" id=\"results\">\n                  <col width=\"200px\">\n                  <col width=\"400px\">\n                  <col width=\"800px\">";
 //if (filtered if requested) result set is not empty:
 if ($auction_set) {
     foreach ($auction_set as $auction) {
コード例 #2
0
function query_select_user_rating_failure()
{
    $user_id = 272;
    $result = query_select_user_rating($user_id);
    assert($result['stars'] == 0);
    assert($result['occurrences'] == 0);
}