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

  • Home
  • SEARCH
  • 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 6572169
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T14:58:20+00:00 2026-05-25T14:58:20+00:00

Situation Consider I’ve got the following class structure: // a user model class UserModel

  • 0

Situation

Consider I’ve got the following class structure:

// a user model
class UserModel extends BaseModel {
    protected static $table = 'Users';
}

// a controller for the user model 
class UserModelController extends BaseModelController {
    protected static $model = 'UserModel';
}

// a base model
class BaseModel {
    protected static $table = '';
}

// a base model controller
class BaseModelController {
    protected static $model = '';
}

What I want

What I want to do now is to have basic functionality in both base controller and base model, for example adding the function delete() into the BaseModelController:

public static function delete($id) {
    $stmt = Database::prepare('DELETE FROM `' . $table . '` WHERE `id`=?');
    $res  = $stmt->execute(array($id));
}

The problem

How do I get the table name? Theoretically I am searching for something like the following:

$table = static::$model::$table;

But, unfortunately this does not work. Is this even possible?

  • 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-05-25T14:58:20+00:00Added an answer on May 25, 2026 at 2:58 pm

    You need to save static::$model into a temporary variable:

    $model = static::$model;
    $table = $model::$table;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Consider the following situation file: ./include/functions/table-config.php containing: . . $tablePages = 'orweb_pages'; . .
Consider the following situation class URISplit { var $REQ_URI; //some more variables function __construct($uri)
Consider the following situation: Class** array = new Class*[8]; array[1] = new Class(1,2); Is
Consider following situation: there is ComboBox and a filter TextBox, then user types a
I'm looking for mutex/semaphore/concurrency mechanism in shell script. Consider following situation: Unless a user
Consider situation when we have a class with couple of static methods that use
Consider the following situation: [Export] class A { } class B { [Import] private
So, please consider the following situation I have a super class of type Shapes
Consider the following situation Code was added to the trunk at revision x A
Consider the following situation: WidgetCompany produced a .NET DLL in 2006 called Widget.dll, version

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.