- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在使用 CodeIgniter。我需要了解 where
和 or_where
条件如何在 codeigniter 查询生成器中工作。
我需要这样的输出 where a=""AND b=""AND c=""OR d=""AND e=""
所以我尝试了一个关联数组。
$where= array('a'=>$firstname,'b'=>$lastname,'c'=>1);
$or_where= array('d' =>$customer_mobile,'e'=>1);
但是我得到了输出其中 a=""AND b=""AND c=""OR d=""OR e=""
你愿意帮忙吗?
是的,我的问题不同。我询问了 or_where
条件。请检查我的期望输出和获取输出。重复的问题是不同的。
最佳答案
希望这对您有帮助:
像这样使用查询分组
:根据您的需要更改表名
和变量
$firstname = 'a';
$lastname = 'b';
$customer_mobile = 'd';
$this->db->select('*')->from('users')
->group_start()
->where('a', $firstname)
->where('b', $lastname)
->where('c', '1')
->or_group_start()
->where('d', $customer_mobile)
->where('e', '1')
->group_end()
->group_end()
->get();
echo $this->db->last_query();
输出将是这样的:
SELECT * FROM `users`
WHERE ( `a` = 'a' AND `b` = 'b' AND `c` = '1'
OR ( `d` = 'd' AND `e` = '1' ) )
更多信息:https://www.codeigniter.com/user_guide/database/query_builder.html#query-grouping
关于php - 如何在 CodeIgniter 中使用 OR_Where 和 AND 条件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51725631/
我该如何做才能满足以下条件: $this->db->where('msgto.msgto_display', 'y'); $this->db->where('msgto.msgto_unread',
我在 CodeIgniter 上使用 Active Record。我对我应该采取哪种方法感到困惑。目前,我们的登录系统让用户使用用户名/电子邮件以及密码登录。但是我目前的事件记录,如果用户选择使用电子
我正在尝试使用 codeigniter 的事件记录执行以下 SQL 查询: SELECT * FROM USERS_OPTIONS WHERE user_id = 3 AND (option_id =
有没有AR#or_where在 Rails 3 中 User.where(cond1).or_where(cond2) ? 最佳答案 Rails 中没有这样的方法。 我认为在 WHERE 子句中执行
我需要使用 codeigniter 在同一字段上运行条件为 where 和 or_where 的查询。还有其他字段执行操作的地方。代码, function get_newTapal($off, $st
我正在尝试在模型中指定查询 $this->db ->select('*') ->from('library') ->where('library.rat
我有一个查询模型。但是第二个 or_where 不工作 模型 $this->db->select('st_student.st_id'); $this->db->from('st_st
我正在尝试在我的模型中指定一个查询 $this->db ->select('*') ->from('library') ->where('library
我正在尝试将 OR WHERE 查询为可标记行为的查询,就像这样...... Business.tagged_with(params[:query], :any => true) 但我也想同时表演一个
如果我使用单个where,搜索就可以,但是多个where在代码点火器的ajax数据表中不起作用。我使用了不同类型的 where,正如您在注释的代码中看到的那样,除了单个 where 之外,没有任何效果
我正在尝试从数据库中获取一个 result_array(),其中两列必须返回 true,反之亦然,所以我决定使用 or_where 但我的代码是返回 Call to undefined method
我正在使用 CodeIgniter。我需要了解 where 和 or_where 条件如何在 codeigniter 查询生成器中工作。 我需要这样的输出 where a=""AND b=""AND
我有这个代码: $this->db->where('status',1); $this->db->where('category',$category_id); $this->
我是一名优秀的程序员,十分优秀!