Yii 프레임 워크에서 "정의되지 않은 오프셋"오류가 있습니다. 다음 ID가 null 인 경우 첫 번째 ID로 이동해야하며 이전 ID가 null 인 경우 마지막 ID가 필요합니까?Yii에 정의되지 않은 오프셋 오류
public static function getNextOrPrevId($currentId, $nextOrPrev)
{
$records=NULL;
if($nextOrPrev == "prev")
$order="id DESC";
if($nextOrPrev == "next")
$order="id ASC";
$records=Photo::model()->findAll(
array('select'=>'id', 'order'=>$order)
);
foreach($records as $i=>$r)
if($r->id == $currentId)
return $records[$i+1]->id ? $records[$i+1]->id : NULL;
return NULL;
}
오류 라인
return $records[$i+1]->id ? $records[$i+1]->id : NULL;
"이전 ID가 null 인 경우 마지막 ID는 무엇을 의미합니까?" ? –