我有一堂课说照片和代码
class photo
{
public function __construct($UserWhosePhotoToBeGetObj)
{
$this->UserWhosePhotoToBeGetObj = $UserWhosePhotoToBeGetObj
}
}
public function getPhoto()
{
// some complex logic and query to get detail of photo of user.
}
现在的问题是,当我想获取多个用户的照片时,如果我在循环中调用这个类,那么将触发许多查询,如果我创建类photoArr
,那么我需要在两个类中编写复杂的逻辑。