if (mysqli_multi_query($link, $wsql)) { do { if ($result = mysqli_store_result($link)) { mysqli_free_result($result); } } while (mysqli_more_results($link) && mysqli_next_result($link)); }
1 <?php 2 echo phpinfo(); 3 function w_db_in_w($link, $fk_countrycode, $fk_categoryid, $wmax_grab_date, $wmin_grab_date, $year, $week) 4 { 5 mysqli_query($link, 'SET group_concat_max_len=8192'); 6 $sql = 'SELECT GROUP_CONCAT(amzid) AS wsum FROM ( SELECT amzid FROM grab_amz_sales_ranking WHERE countrycode="' . $fk_countrycode . '" AND w_categoryid=' . $fk_categoryid . ' AND grab_amz_date>=' . $wmin_grab_date . ' AND grab_amz_date<=' . $wmax_grab_date . ' AND grab_page_rank<101 ORDER BY w_sale DESC LIMIT 100 ) AS w192'; 7 8 $w_amzidlist = db_single_row_single_field_link($link, $sql, 'wsum'); 9 10 if (!empty($w_amzidlist)) { 11 $sql = 'INSERT INTO sales ranking_week (history_year,history_week,fk_countrycode,fk_categoryid,amzidlist100_amzids) VALUES ( ' . $year . ',' . $week . ',"' . $fk_countrycode . '",' . $fk_categoryid . ',"' . $w_amzidlist . ' ");'; 12 $w_id = gen_this_insert_id_link($sql, $link); 13 $wkey = 'sales ranking_week_id'; 14 $sql = 'SELECT SUM(w_sale) AS wsum FROM ( SELECT w_sale FROM grab_amz_sales_ranking WHERE countrycode="' . $fk_countrycode . '" AND w_categoryid=' . $fk_categoryid . ' AND grab_amz_date>=' . $wmin_grab_date . ' AND grab_amz_date<=' . $wmax_grab_date . ') AS w'; 15 $w_amount_all = db_single_row_single_field_link($link, $sql, 'wsum'); 16 $wsql = 'UPDATE sales ranking_week SET amount_all = ' . $w_amount_all . ' WHERE ' . $wkey . '=' . $w_id . ';'; 17 if ($w_amount_all > 0) { 18 for ($w = 100; $w >= 10; $w = $w - 10) { 19 $sql = 'SELECT SUM(w_sale) AS wsum FROM ( SELECT w_sale FROM grab_amz_sales_ranking WHERE countrycode="' . $fk_countrycode . '" AND w_categoryid=' . $fk_categoryid . ' AND grab_amz_date>=' . $wmin_grab_date . ' AND grab_amz_date<=' . $wmax_grab_date . ' AND grab_page_rank<' . ($w + 1) . ' ORDER BY w_sale DESC LIMIT ' . $w . ') AS w'; 20 $w_res = db_single_row_single_field_link($link, $sql, 'wsum'); 21 $wsql .= 'UPDATE sales ranking_week SET amount_' . $w . ' = ' . $w_res . ' WHERE ' . $wkey . '=' . $w_id . ';'; 22 } 23 } 24 /* 25 * mysqli_multi_query($link,$wsql); 26 * WRONG 27 * 2016-12-20 15:49:01 28 PHP Version 5.3.29 29 * */ 30 // 31 if (mysqli_multi_query($link, $wsql)) { 32 do { 33 if ($result = mysqli_store_result($link)) { 34 mysqli_free_result($result); 35 } 36 } while (mysqli_next_result($link)); 37 } 38 } 39 }
Strict Standards: mysqli_next_result() [function.mysqli-next-result]: There is no next result set. Please, call mysqli_more_results()/mysqli::more_results() to check whether to call this function/method