Welcome Guest, Not a member yet? Register   Sign In
Unable to return array from function
#5

[eluser]TheFuzzy0ne[/eluser]
Ideally, your method should always return something other than void, like FALSE. Then you can test that you've actually got a result returned. If you add a die statement to the end of that method, I you may find it triggers sometimes. A more fluid code layout might look something like this:

Code:
function get_breadcrumb($id=NULL)
{
    $id = (int)$id;
    $breadcrumb = array();
    
    $res = $this->db->get_where('categories', array('id' => $id));
    
    if ($res->num_rows() > 0)
    {
        $row = $res->row_array();
        
        if ($row['parentid'])
        {
            $breadcrumb = array_merge($breadcrumb, $this->get_breadcrumb($row['parentid']));
        }
    }
    
    return $breadcrumb;
}

It's untested, but I think it might work.


Messages In This Thread
Unable to return array from function - by El Forum - 05-20-2009, 02:09 AM
Unable to return array from function - by El Forum - 05-20-2009, 02:41 AM
Unable to return array from function - by El Forum - 05-20-2009, 04:10 AM
Unable to return array from function - by El Forum - 05-24-2009, 07:35 AM
Unable to return array from function - by El Forum - 05-24-2009, 08:19 AM



Theme © iAndrew 2016 - Forum software by © MyBB