【发布时间】:2014-02-14 05:26:53
【问题描述】:
我有这张桌子:
id sh_id meta_key meta_value
1 1 country 111
2 1 state 10
3 1 city 5
4 2 country 110
5 4 state 11
....
我会将一个数组值传递给函数。并且数组包含如下值
$array = array('country_id'=>111,'state_id'=>10,'city_id'=>1);
function getValue($array)
我想得到那些数组值的结果应该与 meta_key 和 meta_value 匹配
例如:查询匹配数组的 country_id 值,meta_value 和 meta_key 'country' 以及 state 和 city
它应该在一个查询中。
我已经尝试了以下查询,但它不起作用
$this->db->where('meta_key', 'country');
$this->db->or_where('meta_value', $array['country_id']);
$this->db->where('meta_key', 'state');
$this->db->or_where('meta_value', $array['state_id']);
$query = $this->db->get("at_featured_shops");
【问题讨论】: