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 像这种代码要怎么跑起来?
  • ¥15 怎么改成循环输入删除(语言-c语言)
  • ¥15 安卓C读取/dev/fastpipe屏幕像素数据
  • ¥15 pyqt5tools安装失败
  • ¥15 mmdetection
  • ¥15 nginx代理报502的错误
  • ¥100 当AWR1843发送完设置的固定帧后,如何使其再发送第一次的帧
  • ¥15 图示五个参数的模型校正是用什么方法做出来的。如何建立其他模型
  • ¥100 描述一下元器件的基本功能,pcba板的基本原理
  • ¥15 STM32无法向设备写入固件