时间:2021-07-01 10:21:17 帮助过:10人阅读
function UpdateDeliveryNumber($number){
$sql=new MYSQL();
$n_qz=$number.date("md");
$head=str_pad($n_qz,12,0);
$sqlstr="SELECT group_concat(`order_id`) FROM `Sale_Order` “;
$sqlstr.="WHERE `number`=$number GROUP BY `recipient_name`,`ship_address`,`delivery_area`";
$sqlstr.="ORDER BY length(group_concat(`order_id`)) DESC ";
$query=$sql->query($sqlstr);
echo $sqlstr."
";
echo $sql->num_rows($query)."
";
if($sql->num_rows($query)){//判断是否查询到记录
while($rs=$sql->fetch_array($query)){
echo "select OK";
$sql_item="UPDATE `Sale_Order` SET `delivery_number`='$head' WHERE `order_id`='' ";
$order_item_id=explode(",",$rs["group_concat(`order_id`)"]);
echo $rs["group_concat(`order_id`)"]."
";
foreach($order_item_id as $n)
{
$sql_item.=" OR `order_id`='$n' ";
}
echo $head."
";
$head++;
echo $sql_item."
";
$query_item=$sql->query($sql_item);
echo $query_item;
}
}
}
UpdateDeliveryNumber(21);
echo "OK";
SELECT group_concat(`order_id`) FROM `Sale_Order` WHERE `number`=21 GROUP BY `recipient_name`,`ship_address`,`delivery_area` ORDER BY length(group_concat(`order_id`)) DESC
2
select OK114-4278868-5227463
210323000000
UPDATE `Sale_Order` SET `delivery_number`='210323000000' WHERE `order_id`='' OR `order_id`='114-4278868-5227463'
Warning: mysql_fetch_assoc() expects parameter 1 to be resource, boolean given in /var/www/html/demo/class/mysql.class.php on line 53 OK