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
#12

[eluser]D.Phil[/eluser]
Here try these modifications:

function get_bus_id()
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);
    $this->db->limit(1);
    $query = $this->db->get();
    if ($query->num_rows() > 0) {
        $row = $query->row();
        return $row->id();
    } else return false;
}

function do_upload()
Code:
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,
    );
    
    echo var_dump($bus_id);
    
    $this->db->insert('photos', $data);
}


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, 02:01 PM



Theme © iAndrew 2016 - Forum software by © MyBB