Monday, 1 September 2008

PHP: Cannot use object of type stdClass

When handling object, you have to remember to retieve LIKE an object, NOT an like array style.

Example Object retrieval:

PHP Example
Make sure you just use

echo $response->TransactionID;
echo $response['TransactionID'];

Zend Framework
[ ZEND_DB Example ]
When handling You must remember to set the db adaptor to fetch object, so anything returned will fetched as a proper object.

$result = $this->db->fetchRow($select);
echo $result->columnNameToFetch;

No comments: