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 keil的map文件中Image component sizes各项意思
  • ¥30 BC260Y用MQTT向阿里云发布主题消息一直错误
  • ¥20 求个正点原子stm32f407开发版的贪吃蛇游戏
  • ¥15 划分vlan后,链路不通了?
  • ¥20 求各位懂行的人,注册表能不能看到usb使用得具体信息,干了什么,传输了什么数据
  • ¥15 Vue3 大型图片数据拖动排序
  • ¥15 Centos / PETGEM
  • ¥15 划分vlan后不通了
  • ¥20 用雷电模拟器安装百达屋apk一直闪退
  • ¥15 算能科技20240506咨询(拒绝大模型回答)