Trying To Get Property Of Non-Object

Hi,

this is my sample code,




public function getIncome($regid){

   $commissionbank = new CommissionBank;

   $criteria=new CDbCriteria;

   $criteria->condition = 'ReceiverID =:regID';

   $criteria->params=array(':regID'=>$regid);

   $criteria->select = 'sum(DepositeAmount) as amount';

   $criteria->group = 'ReceiverID';

   $income = $commissionbank->model()->find($criteria);

   return $income->amount;

}



this function is working properly before i updated my PHP version , after that when result is Null i am getting error as: " Trying to get property of non-object "

so , what is solution for this problem, the same way i am using in so many function.

Check if $income is null




$amount = 0;


if ($income)

{

    $amount = $income->amount;

}


return $amount;


//OR


return ($income) ? $income->amount : 0;



thanks , but why before update my version it was working properly?

if i check that return value is null or not , it’s OK , but i should do it iin all my function?

any other idea?