duandianzhong8315 2013-07-09 11:51
浏览 41
已采纳

在codeigniter中选择和where条件

In this coding iam checking the whether email id is present in database.After that i need to change password.

function user_password($input, $serviceName){
        $ipJson = json_encode($input);
        $updateArray = array(
            'email' => $input['email'],
            'password' => md5($input['password']),
            'user_modified_date' => date('Y-m-d H:i:s'),
        );
        $this->db->where('email', $input['email']);
        $update = $this->db->update('users', $updateArray);
        if ($update) {
            $data['message'] = 'email id is present';
            $status = $this->clamo_lib->return_status('success', $serviceName, $data, $ipJson);
        } 
        else {
            $data['message'] = 'Error In Updating Please Check Your Email ID';
            $status = $this->clamo_lib->return_status('error', $serviceName, $data, $ipJson);
        }
        return $status;
    }

if email is present in db i need to get "email id is present" message else i need to get "error"message.how i need to check the condition.

  • 写回答

2条回答 默认 最新

  • 普通网友 2013-07-09 12:04
    关注

    As you need to check that email address already in use or not. So in model

    $this->db->where("email",$input['email']);
    $query = $this->db->get("users");
    if($query->num_rows()>0){
       $status['message'] = 'Email Already Exist';
    }
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 python验证码滑块图像识别
  • ¥15 QT6颜色选择对话框显示不完整
  • ¥20 能提供一下思路或者代码吗
  • ¥15 用twincat控制!
  • ¥15 请问一下这个运行结果是怎么来的
  • ¥15 单通道放大电路的工作原理
  • ¥30 YOLO检测微调结果p为1
  • ¥15 DS18B20内部ADC模数转换器
  • ¥15 做个有关计算的小程序
  • ¥15 如何用MATLAB实现以下三个公式(有相互嵌套)