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

[eluser]vitoco[/eluser]
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);
        $query = $this->db->get();
            if ($query->num_rows() > 0) {
              // RESULT ARRAY RETURN A MULTIDIMENSIONAL ARRAY e.g. ARRAY OF DB RECORDS
              // ( ROWS ), SO IT DOENS'T FIT
              //return $query->result_array();
              // THE CORRECT METHOD IS row_array(), THAT RETURN THE FIRST ROW OF THE
              // RECORDSET
              return $query->row_array();
            }
        }
Code:
....
$upload = $this->upload->data();
        $bus_id = $this->get_bus_id();
        // CHECK THE DATA RETURNED BY THE MODEL
        echo '<pre>'.print_r( $bus_id , true ).'</pre>';
        
        /*
        TABLE STRUCTURE =============
            id, the row ID
            photoname
            thumb
            fullsize
            busid
            userid
        */
        
        $data = array(
            'id'        => 0 , // I GUESS IS AUTO_INCREMENT
            'photoname'    => ''
            'thumb'        => $this->gallery_path . '/thumbs/' . $upload['file_name'],
            'fullsize'    => $upload['full_path'],
            'busid'=> $bus_id['id'],
            'userid' => $this->tank_auth->get_user_id(),
        );
        // CHED THE DATA CREATED FOR INSERT
        echo '<pre>'.print_r( $data , true ).'</pre>';
        
        $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:43 PM



Theme © iAndrew 2016 - Forum software by © MyBB