Trying To Get Property Of Non-Object


this is my sample code,

public function getIncome($regid){

   $commissionbank = new CommissionBank;

   $criteria=new CDbCriteria;

   $criteria->condition = 'ReceiverID =: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;


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?