Welcome Guest, Not a member yet? Register   Sign In
Pass query result to 2nd function
#1

[eluser]Unknown[/eluser]
Hoping someone can help me with this. I've been using PHP for a while, but am new to Codeigniter.

Basically I have two tables on two seperate databases called 'photos' and 'users'. 'photos' contains info regarding the photo the user wants to view, and then 'users' contains info on the user who owns that photo.

Here's the code:

Code:
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Viewphoto_model extends CI_Model {


    public function get_photo($id)
    {
        $db_photos = $this->load->database('photos', TRUE);
        $db_photos->select('*');
        $db_photos->select("DATE_FORMAT(uploaddate, '%d/%m/%y') as uploaddate_formatted", FALSE);
        $db_photos->from('photos');
        $db_photos->where('approved', '1');
        $db_photos->where('id', $id);

        $query = $db_photos->get();
        return $query->row();
    }
}

In the 'photos' table on the 'photos' database is a field called 'userid'. I need to, in the above function, create a variable of this value (based on the query above) and then pass this variable to a 2nd function and then run a 2nd query on it.

How can I do that?

Thanks!




Theme © iAndrew 2016 - Forum software by © MyBB