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 8329551
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T01:49:49+00:00 2026-06-09T01:49:49+00:00

I have a separate classes for each MySQL table I have in my PHP

  • 0

I have a separate classes for each MySQL table I have in my PHP project. The class would be something like this:

class students  {

  public static function find_all() {
        return self::sql_finder("SELECT * FROM ".get_class());
  }

}

I use the same class for almost all the table I have in my project, except I change the class name as table name. Now you can see I used “get_class()” in the function used in the class, so the SQL takes the table name from the class name.

Since I have too many functions in the class which I use in all the classes, I plan to extend the class with the sub class something like this:

class  class_with_all_the_common_functions {
 public static function find_all() {
        return self::sql_finder("SELECT * FROM ".get_class());
  }
}

class student extends class_with_all_the_common_functions {
 // some table specific functions
}

Now when I use student::find_all() it shows an error:

Database query failed: Table 'dr.class_with_all_the_common_functions
doesn't exist

I think it makes the point clear, I want the find_all() to be executed as it is executing in the class student. Is that something which is possible through late static binding?

  • 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-09T01:49:53+00:00Added an answer on June 9, 2026 at 1:49 am

    Two things you will find helpful related to this:

    • get_called_class() instead of get_class()
    • static::foo() instead of self::foo()
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have separate repository classes for each entity. Now I would like to implement
I have a data access layer that has separate classes for each table in
Pretend you have a class like this one: public class CreateUserRequest { ... @NotNull
Say I have two separate classes, A and B. I also have Repository class
Working in Java: I have a JFrame class, and separate classes for my two
I have an interface that I want to implement in separate classes after doing
Alright so I have been trying to get all of my separate classes (At
Do I need to have separate/multiple workers to run multiple websites (each with a
I have a class RequestDetail . There are 2 classes classA and classB derived
It seems boost::asio defines a separate endpoint class for each protocol, which is irritating

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.