Case 1: I get an array of CActiveRecords and try to loop over it as shown below:
foreach ($pendingTasks as $task)
{
if($task->task->employee_id
Because of the tasks
in $pendingTasks
must not have a relation. You can check by simply adding an isset()
like so:
foreach ($pendingTasks as $task) {
if(isset($task->task) && $task->task->employee_id=="1") {
//some logic here
} else {
echo "{$task->id} doesn't have a task relation";
}
}
Assuming $pendingTasks
are instances of TaskLog
also.