Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/codeigniter/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 在codeigniter中选择和放置条件_Php_Codeigniter - Fatal编程技术网

Php 在codeigniter中选择和放置条件

Php 在codeigniter中选择和放置条件,php,codeigniter,Php,Codeigniter,在此编码中,我检查数据库中是否存在电子邮件id。之后我需要更改密码 function user_password($input, $serviceName){ $ipJson = json_encode($input); $updateArray = array( 'email' => $input['email'], 'password' => md5($input['password']),

在此编码中,我检查数据库中是否存在电子邮件id。之后我需要更改密码

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;
    }

如果数据库中存在电子邮件,我需要获取“电子邮件id存在”消息,否则我需要获取“错误”消息。我需要如何检查条件。

因为您需要检查该电子邮件地址是否已在使用中。 所以在模型中

$this->db->where("email",$input['email']);
$query = $this->db->get("users");
if($query->num_rows()>0){
   $status['message'] = 'Email Already Exist';
}
//在模型中更改更新函数,如下所示:

function update('users',$updatearray)
{
    if(is_array($dataarray))
    {
       $this->db->trans_start();
       $this->db->where('email',$this->input->post('email'));
       $this->db->update('table',$updatearray);
       $this->db->trans_complete();
       return TRUE;
    }
    else
    {
       return FALSE
    }

}

我想你想在电子邮件上更新基地吗?如果记录的更新超过了您想要打印的“电子邮件存在”?在更新之前,我需要检查我需要写的内容,而不是If($update),而不是If($upadate)行我需要写If($this->db->impacted_rows()>0)当您要检查任何行是否受您的查询影响时,您将使用该行。现在,if正文将检查电子邮件是否存在。如果它存在,您可以从那里返回并显示电子邮件存在的消息。在else部分中编写更新代码。
function update('users',$updatearray)
{
    if(is_array($dataarray))
    {
       $this->db->trans_start();
       $this->db->where('email',$this->input->post('email'));
       $this->db->update('table',$updatearray);
       $this->db->trans_complete();
       return TRUE;
    }
    else
    {
       return FALSE
    }

}