CodeIgniter Forums
Why an object is passed as an array? [CLOSED] - 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: Why an object is passed as an array? [CLOSED] (/showthread.php?tid=32319)



Why an object is passed as an array? [CLOSED] - El Forum - 07-20-2010

[eluser]earlyriser[/eluser]
Hi I have this code in my controller:

Code:
//bills loop. This objects array comes from a $query->result()
foreach ( $bills as $bill)
{    
     echo $bill->bill_status;  //WORKS AS I EXPECTED
     $this->Bill_model->process_bill ( $bill );    
}

And I have this in my Bill_model

Code:
function process_bill( $bill)
{
     echo $bill->bill_status; //ERROR
     echo $bill['bill_status'];  //WORKS AS I UNEXPECTED
}

The error I get is Message: Trying to get property of non-object

Why the object is passed as an array? What's the way to pass this object?

UPDATE:
It was a typing error, thanks