예제 #1
0
 function relatedItems($itemID, $pageId, $uid = null)
 {
     $arr = array('id' => $itemID);
     $re = ItemInfo::iteminfo_select($arr, $limit);
     $data = array();
     $line = mysql_fetch_array($re, MYSQL_ASSOC);
     $items = $line['relatedItems'];
     if (!empty($items)) {
         $ids = explode(",", $items);
         $data = array();
         foreach ($ids as $key => $value) {
             //取字段,分隔处理....
             $arr = array('id' => $itemID);
             $itemsNum = 5;
             //控制次调用返回的数据数量$itemsNum-1个
             $from = $itemsNum * ($pageId - 1);
             $to = $itemsNum * $pageId - 1;
             $limit = ' ' . $from . ',' . $to . ' ';
             // 每页4条数据
             $re = ItemInfo::iteminfo_select($arr, $limit);
             while ($line = mysql_fetch_array($re, MYSQL_ASSOC)) {
                 $favorite = self::isFavorite($itemID, $uid);
                 $data[] = array($value => array('itemName' => $line['itemName'], 'itemPrice' => $line['itemPrice'], 'itemPic' => $line['itemPic'], 'isFavorite' => $favorite));
             }
         }
     }
     return $data;
 }