Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9169363
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T15:52:01+00:00 2026-06-17T15:52:01+00:00

I have a class say photo and code like class photo { public function

  • 0

I have a class say photo and code like

class photo  
{  
    public function __construct($UserWhosePhotoToBeGetObj)  
    {    
       $this->UserWhosePhotoToBeGetObj = $UserWhosePhotoToBeGetObj  
    }  
}

public function getPhoto()  
{  
   // some complex logic and query to get detail of photo of user.  
}

Now the problem is when i want to get photo of multiple users and if i called this class in loop, then many query will be fired and if I create class photoArr then I need to write complex logic in both classes.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T15:52:04+00:00Added an answer on June 17, 2026 at 3:52 pm

    “photo” sounds like a data class. Data classes should not contain logic for fetching things. Passing in an “user for which to get photo” in the constructor seems rather wrong as well.

    Such logic should probably go in a PhotoFetcher class that has the logic your current getPhoto has. For instance getPhotoForUser( User $userForWhichToGetPhoto ). It could also support batch fetching.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

say I have: class Test { public static int Hello = 5; } This
Let's say i have many models like that: class ExampleModel(models.Model): photo = models.ImageField(upload_to='photos/') image
Let's say I have a class that implements the IDisposable interface. Something like this:
Let's say I have: class Like(db.Model): user = db.ReferenceProperty(User,collection_name='likes') photo = db.ReferenceProperty(Photo,collection_name='likes_received') created =
I have this one class: say InterClass . This class is declared in say,
let's say I have class Dummy { String a, b; public Dummy(String a, String
Lets say I have: class X { function a() { echo Hello, ; }
Let's say that I have class , that uses some functionality of dict .
I have a class say public class CostStore { int DirectorateId { get; set;
I am using Qt 4.5 so do C++. I have a class like this

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.