Welcome Guest, Not a member yet? Register   Sign In
Trying to pass variable from 1 Function to Another to Put in Array within same Model
#1

[eluser]jshultz[/eluser]
Ok, that sounds really confusing. What I'm trying to do is this. I've got a function that uploads/resizes photos to the server. It stores the paths in the DB. I need to attach the id of the business to the row of photos.

Here's what I have so far:

Code:
function get_bus_id() {
        $userid = $this->tank_auth->get_user_id();
        $this->db->select('b.id');
        $this->db->from ('business AS b');
        $this->db->where ('b.userid', $userid);
        return $this->db->get();
    }

That get's the id of the business. Then, I have my upload function which is below:

Code:
/* Uploads images to the site and adds to the database. */
    function do_upload() {
        
        $config = array(
            'allowed_types' => 'jpg|jpeg|gif|png',
            'upload_path' => $this->gallery_path,
            'max_size' => 2000
        );
        
        $this->load->library('upload', $config);
        $this->upload->do_upload();
        $image_data = $this->upload->data();
        
        $config = array(
            'source_image' => $image_data['full_path'],
            'new_image' => $this->gallery_path . '/thumbs',
            'maintain_ratio' => true,
            'width' => 150,
            'height' => 100
        );
        
        $this->load->library('image_lib', $config);
        $this->image_lib->resize();
        
        $upload = $this->upload->data();
        $bus_id = $this->get_bus_id();
        
        $data = array(
            'userid' => $this->tank_auth->get_user_id(),
            'thumb' => $this->gallery_path . '/thumbs/' . $upload['file_name'],
            'fullsize' => $upload['full_path'],
            'busid'=> $bus_id['query'],
        );
        
        echo var_dump($bus_id);
        
        $this->db->insert('photos', $data);
    }

The problem I'm getting is the following:

Fatal error: Cannot use object of type CI_DB_mysql_result as array in /home/welcomet/public_html/application/models/gallery_model.php on line 48

I've tried all sorts of ways to get the value over, but my limited knowledge keeps getting in the way. Any help would be really appreciated.


Messages In This Thread
Trying to pass variable from 1 Function to Another to Put in Array within same Model - by El Forum - 05-24-2010, 11:30 AM



Theme © iAndrew 2016 - Forum software by © MyBB