Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/266.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,我想在Codeigniter中使用以下查询: SELECT `users` . * , `users_profile` . * FROM (`users`) LEFT JOIN `users_profile` ON `users`.`id` = `users_profile`.`users_id` WHERE (`loginid` = '$username' OR `email` = '$username' ) AND `password` = '$password' AND `users`.`

我想在Codeigniter中使用以下查询:

SELECT `users` . * , `users_profile` . * FROM (`users`) LEFT JOIN `users_profile`
ON `users`.`id` = `users_profile`.`users_id`
WHERE (`loginid` = '$username' OR `email` = '$username' )
AND `password` = '$password' AND `users`.`status` = 'A' LIMIT 1 
它工作正常,但当我以Codeigniter格式编写此查询时:

$this->db->where('loginid',"$username");
$this->db->or_where('email', "$username");    
$this->db->where('password',MD5($password));
$this->db->where('users.status','A');
$this->db->limit(1);

它将始终返回true what is right syntax?

您应该使用where的自定义字符串方法,因为仅使用ActiveRecord无法直接执行此操作。请参阅并滚动至where功能下的第四个选项

例如:

    Custom string:

    You can write your own clauses manually:
    $where = "name='Joe' AND status='boss' OR status='active'";

    $this->db->where($where);

$this->db->where() accepts an optional third parameter. If you set it to FALSE, CodeIgniter will not try to protect your field or table names with backticks.

$this->db->where('MATCH (field) AGAINST ("value")', NULL, FALSE);

您应该使用where的自定义字符串方法,因为仅使用ActiveRecord无法直接执行此操作。请参阅并滚动至where功能下的第四个选项

例如:

    Custom string:

    You can write your own clauses manually:
    $where = "name='Joe' AND status='boss' OR status='active'";

    $this->db->where($where);

$this->db->where() accepts an optional third parameter. If you set it to FALSE, CodeIgniter will not try to protect your field or table names with backticks.

$this->db->where('MATCH (field) AGAINST ("value")', NULL, FALSE);

可能您的查询应该与codeIgniter中的类似……。作为参考,您可以查看此链接


可能您的查询应该与codeIgniter中的类似……。作为参考,您可以查看此链接


您应该阅读以下内容:$this->db->whereloginid='$username'或email='$username'和password='MD5$password和status='A'和id='users\u id;您应该阅读以下内容:$this->db->whereloginid='$username'或email='$username'和password='MD5$password和status='A'和id='users\u id;