php命令行脚本 mock数据

 

 

 

<?php
$con = mysql_connect("192.168.1.5:3306","root","123");
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }

mysql_select_db("e_wms", $con);



function varchar(){
    $string = 'abcdefghkmnprstuvwxyzABCDEFGHKMNPRSTUVWXYZ23456789';
    $str = '';
    for ($i=0; $i < 10; $i++) { 
        $str.= $string[rand(0,strlen($string)-1)];
    }
    return $str;
}

function number(){
    $string = '123456789';
    $str = '';
    for ($i=0; $i < 4; $i++) { 
        $str.= $string[rand(0,strlen($string)-1)];
    }
    return $str;
}


function decimal(){
    $string = '123456789';
    $str = '';
    for ($i=0; $i < 4; $i++) { 
        $str.= $string[rand(0,strlen($string)-1)];
    }
    $str1 = '';
    for ($i=0; $i < 4; $i++) { 
        $str1.= $string[rand(0,strlen($string)-1)];
    }
    $decimal = $str.".".$str1;
    return $decimal;
}

for($i=0;$i<30;$i++){
    $varchar =  varchar();
    $number = number();
    $decimal = decimal();
    
    
    /** sql_set_start **/
    $sql = "INSERT INTO base_goods_weight (goods_no, quantity,weight) VALUES ('".$varchar."', '".$number."', '".$decimal."')";
    echo $sql."+++++++++++++";
    /** sql_set_end **/
    
    mysql_query($sql);
}

?>

 

posted @ 2018-10-10 11:52  fleam  阅读(185)  评论(0编辑  收藏  举报