Welcome Guest, Not a member yet? Register   Sign In
Multiple Database Queries
#1

[eluser]joshvermaire[/eluser]
I'm doing the following queries and can't figure out how to get the second query to work. How do I get an array of just the values from my first query and use that in my second?

Code:
function application()
    {
        $user_id = $this->tank_auth->get_user_id();
        $this->db->select('app_id')->from('using')->where('user_id' , $user_id);
        $query = $this->db->get();

        $row = $query->result_array();

        if ($query->num_rows() > 0) :
        $this->db->select('app_name')->from('applications')->where('id' , $row['app_id']);
        $body['query'] = $this->db->get();
        endif;

        $this->load->view('apps_view', $body);

If I comment out the second query and
Code:
var_dump($row);
it gives me:
array(2) { [0]=> array(1) { ["app_id"]=> string(1) "2" } [1]=> array(1) { ["app_id"]=> string(1) "3" } }

I decided to do multiple queries instead of a join because I will be adding additional columns to select from the second query.


Messages In This Thread
Multiple Database Queries - by El Forum - 02-14-2011, 04:07 AM
Multiple Database Queries - by El Forum - 02-14-2011, 12:21 PM
Multiple Database Queries - by El Forum - 02-14-2011, 02:03 PM
Multiple Database Queries - by El Forum - 02-14-2011, 02:26 PM
Multiple Database Queries - by El Forum - 02-14-2011, 02:38 PM
Multiple Database Queries - by El Forum - 02-14-2011, 03:09 PM
Multiple Database Queries - by El Forum - 02-14-2011, 03:15 PM
Multiple Database Queries - by El Forum - 02-14-2011, 05:18 PM



Theme © iAndrew 2016 - Forum software by © MyBB