[eluser]Wondering Coder[/eluser]
I like the part of CI active record where I can have a dynamic where clause using get_where().
Code:
My controller
$cond = array('user_id'=>1,'data_id'=>2)
$this->model->get_logged_user($cond);
My model
function get_logged_user($data)
{
$this->db->select('user_id, data_id, coor_id, image');
$query = $this->db->get_where('users',$data);
return $query;
but now I'm using a subquery and since CI active record doesn't support subquery, I write my query like this below.
Code:
function get_logged_user($userid,$dataid)
{
$query = $this->db->query("SELECT user_id, data_id, coor_id, image FROM (
SELECT ad_userid user_id, ad_dataid data_id, '' coor_id, image FROM pps_admin_users
UNION
SELECT user_id, data_id, coor_id, image FROM pps_users) b
WHERE b.user_id=$userid AND b.data_id=$dataid",FALSE);
return $query;
}
but now my problem is how can I have the same functionality in get_where without using CI active. coz I'll be using again this query but with different where clause. Anyone have an idea here?