private function get_uniqid_id($model_name, $len = 6)
 {
     while (strlen($product_id = intval(creat_rand_str(6, 'numeric'))) != 6) {
     }
     $product_info_model = M($model_name);
     if ($model_name == 'group_info') {
         $field = 'group_id';
     } else {
         $field = 'product_id';
     }
     $product_info = $product_info_model->where($field . ' = %d', $product_id)->select();
     if (!empty($product_info)) {
         $product_id = $this->get_uniqid_id($model_name, $len);
     }
     return $product_id;
 }
Example #2
0
 public function get_user_id_unique()
 {
     $user_id = creat_rand_str(6, 'numeric');
     $user_model = D('user');
     if (!$user_model->where('uid =%d', $user_id)->find() && strlen(floor($user_id)) == 6) {
         return $user_id;
     }
     return $this->get_user_id_unique();
 }
 private function get_product_id()
 {
     while (strlen($product_id = intval(creat_rand_str(6, 'numeric'))) != 6) {
     }
     $product_info_model = M('product_info');
     $product_info = $product_info_model->where('product_id = %d', $product_id)->select();
     if (!empty($product_info)) {
         $product_id = $this->get_product_id();
     }
     return $product_id;
 }