2

So I have this method to retrieve my data:

    public function retrieve_not_members($group_id){
        $sql= "SELECT * FROM pnp_officer_tbl WHERE pnp_id NOT IN (SELECT pnp_id FROM group_members_tbl WHERE group_id = ?)";
        $this->db->query($sql, array($group_id));       

        echo $this->db->last_query();

        $query = $this->db->get();
        $data = $this->return_data($query);
        var_dump($data);
        }

It returned false. However, when i tried to query the returned string by $this->db->last_query(); directly in my database it is working properly. Why is that so?

This is the query string returned:

SELECT * FROM pnp_officer_tbl WHERE pnp_id NOT IN (SELECT pnp_id FROM group_members_tbl WHERE group_id = 'GROUP-0002')

I am looking for answers for almost 1 hour now. Thank you!

0

1 Answer 1

2

No, the $this->db->get() is superfluous since you already made an $this->db->query(). After the ->query() method, return the response thru ->result():

public function retrieve_not_members($group_id)
{
    $sql = "SELECT * FROM pnp_officer_tbl WHERE pnp_id NOT IN (SELECT pnp_id FROM group_members_tbl WHERE group_id = ?)";
    $query = $this->db->query($sql, array($group_id));       
    return $query->result();
}
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.