按时间加随机数产生订单includesclassesorder.php:
2、把以下代码插入到order.php中; function create($zf_ot_modules, $zf_mode = 2) { global $db;
插入以下代码: $t1 = date(“YmdGis”); //时间为年月日时分秒,去掉Gis为年月日,即:$t1=date(“Ymd”); srand ((float) microtime() * 10000000); $input = array (“1″, “2″, “3″, “4″, “5″, “6″, “7″, “8″, “9″, “0″); $rand_keys = array_rand ($input, 2); $l1 = $input; $l2 = $input; $r1 = rand(0,9); $ordernum = $t1.$l1.$l2.$r1; //顺便把$11.$12去掉以减少订单位数,即:$ordernum=$t1.$r1;
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ $t1 = date(“YmdGis”); //为减少重复单的情况,设置为获取时分秒 $r1 = rand(0,9); $r2 = rand(0,9); $ordernum = $t1.$r1.$r2;
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ $sql_data_array = array(‘orders_id’ => $ordernum, 查找: zen_db_perform(TABLE_ORDERS, $sql_data_array); 插入: /*修改原来的调用自动插入函数为$ordernum变量*/ $insert_id = $ordernum; 完成,获取的订单位数为16位,1-8位为:年月日,9-14位为时分秒,15-16位为随机2位数 (责任编辑:最模板) |