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

[eluser]vitoco[/eluser]
Try this code, and a question...what happens if the query doesn't return a row ??
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
            $row = $query->row_array();
            echo '<pre>'.print_r( $row , true ).'</pre>';
            return $row ;
        }
        // WHAT HAPPEN IF THE SELECT DOESN'T RETURN A ROW ??
        else
        {
            ;// ???
        }
    }


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



Theme © iAndrew 2016 - Forum software by © MyBB