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

[eluser]jshultz[/eluser]
[quote author="don.phil" date="1274751324"]Can you post both functions again on pastebin or something[/quote]

here you go: http://pastebin.com/juZqtmDJ
#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);
...
#23

[eluser]D.Phil[/eluser]
Try this:
http://pastebin.com/cdZP2tTp

[quote author="jshultz" date="1274751570"][quote author="don.phil" date="1274751324"]Can you post both functions again on pastebin or something[/quote]

here you go: http://pastebin.com/juZqtmDJ[/quote]
#24

[eluser]jshultz[/eluser]
Ok, something happened, I don't know what but things are working:


Array
(
[id] => 5
)
Array
(
[id] => 0
[photoname] =>
[thumb] => /home/welcomet/public_html/assets/images/gallery/thumbs/ATT650948.jpg
[fullsize] => /home/welcomet/public_html/assets/images/gallery/ATT650948.jpg
[busid] => 5
[userid] => 1
)


Can you explain to me how it works? I would like to be able to understand it better.
#25

[eluser]vitoco[/eluser]
my code or don.phil code works ?? Tongue
#26

[eluser]jshultz[/eluser]
[quote author="vitoco" date="1274752517"]my code or don.phil code works ?? Tongue[/quote]

Yours, bro.

Here's the complete working code: http://pastebin.com/UBZYR1DU
#27

[eluser]vitoco[/eluser]
i've added some comments to the code
http://pastebin.com/UBZYR1DU
Saludos
#28

[eluser]jshultz[/eluser]
[quote author="vitoco" date="1274753427"]i've added some comments to the code
http://pastebin.com/UBZYR1DU
Saludos[/quote]

Cool, thank you for your help! Smile




Theme © iAndrew 2016 - Forum software by © MyBB