CodeIgniter Forums
my model function causing memory error - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: my model function causing memory error (/showthread.php?tid=33168)



my model function causing memory error - El Forum - 08-17-2010

[eluser]Corbee[/eluser]
I don't seem to understand why whenever I called this model to my controller, it crashes

Code:
Fatal error: Allowed memory size of 33554432 bytes exhausted (tried to allocate 64 bytes) in C:\xampp\htdocs\...\mysql_result.php on line 147

the model
Code:
function getcarbrands()
    {
        $this->db->from('carbrand');
        $this->db->join('caryear','caryear.brandID = carbrand.brandID','left');
        $this->db->join('carmodel','carmodel.brandID = carbrand.brandID','left');
        $this->db->where("price > 0");    
        $q = $this->db->get();
        
        if ($q->num_rows > 0)
        {
            foreach($q->result_array() as $row)
            {
                $data[] = $row;    
            }
            $q->free_result();
            return $data;
        }
    }

Is there something wrong with my code?


my model function causing memory error - El Forum - 08-17-2010

[eluser]Corbee[/eluser]
Also does this have something to do with autoload?