Rankings of inventory of commercial housing in China

Source: Internet
Author: User

Rankings of inventory of commercial housing in China

1 public function goods_number () 2 {3 // receive item ID 4 $ id = I ('get. id '); 5 $ gnModel = D ('goods _ number'); 6 7 // Process Form 8 if (IS_POST) 9 {
// Var_dump ($ _ POST) die; 10 // Delete the original inventory 11 $ gnModel-> where (array (12 'goods _ id' => array ('eq ', $ id), 13)-> delete (); 14 // var_dump ($ _ POST); die; 15 $ gaid = I ('Post. goods_attr_id '); 16 $ gn = I ('Post. goods_number '); 17 // calculate the ratio of item property ID to inventory 18 $ gaidCount = count ($ gaid); 19 $ gnCount = count ($ gn ); 20 $ rate = $ gaidCount/$ gnCount; 21 // cyclic inventory 22 $ _ I = 0; // obtain the item attributes ID23 foreach ($ gn as $ k => $ v) 24 {25 $ _ goodsAttrId = array (); // Put the IDS obtained below here 26 // then get $ rate from the item attribute ID array, and get a 27 for ($ I = 0 at a time; $ I <$ rate; $ I ++) 28 {29 $ _ goodsAttrId [] = $ gaid [$ _ I]; 30 $ _ I ++; 31} 32 // sort 33 sort ($ _ goodsAttrId, SORT_NUMERIC) in ascending order ); // sort by number 34 // convert the retrieved item property ID to a string of 35 $ _ goodsAttrId = (string) implode (',', $ _ goodsAttrId ); 36 $ gnModel-> add (array (37 'goods _ id' => $ id, 38 'goods _ attr_id '= >$ _ goodsAttrId, 39 'goods _ number' => $ v, 40); 41} 42 $ this-> succes S ('set successfully! ', U ('goods _ number? Id = '. I ('get. id '); 43 exit; 44} 45 46 // retrieve the value of all optional attributes of the item based on the item ID 47 $ gaModel = D ('goods _ attr '); 48 $ gaData = $ gaModel-> alias ('A') 49-> field ('a. *, B. attr_name ') 50-> join ('left JOIN _ ATTRIBUTE _ B ON. attr_id = B. id') 51-> where (array (52 'a. goods_id '=> array ('eq', $ id), 53 'B. attr_type '=> array ('eq', 'optional '), 54)-> select (); 55 // process this two-dimensional array: Convert to 3D: put the same attributes together 56 $ _ gaData = array (); 57 foreach ($ gaData as $ k => $ v) 58 {59 $ _ gaData [$ v ['attr _ name'] [] = $ v; 60} 61 62 // obtain the inventory that has been set for this item 63 $ gnData = $ gnModel-> where (array (64 'goods _ id' => $ id, 65)-> select (); 66 // var_dump ($ gnData); 67 68 $ this-> assign (array (69 'gadata' = >$ _ gaData, 70 'gndata' => $ gnData, 71); 72 73 // set page information 74 $ this-> assign (array (75' _ page_title '=> 'inventory ', 76 '_ page_btn_name' => 'Return list', 77 '_ page_btn_link' => U ('lst'), 78); 79 // 1. display Form 80 $ this-> display (); 81}

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.