
我前一阵子问过。不幸的是,Mysql并没有这样做。我很喜欢它,但事实并非如此。在PHP中,你可以做到这一点。例子:
public function random_id_gen($length) { //the characters you want in your id $characters = '23456789ABCDEFGHJKLMNPQRSTUVWXYZ'; $max = strlen($characters) - 1; $string = ''; for ($i = 0; $i < $length; $i++) { $string .= $characters[mt_rand(0, $max)]; } return $string; }欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)