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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T03:07:43+00:00 2026-05-28T03:07:43+00:00

I write a Model class in PHP and this class has a $db property

  • 0

I write a Model class in PHP and this class has a $db property to store a database class object.

When I derive my class from Model class, if I want to access to $db object I must do this:

class post extends Model
{
    function a()
    {
       return $this->db->find();
       // .....
    }
}

But I want to gain direct access to the database object in the post class, like this:

class post extends Model
{
    function a()
    {
       return $this->find();
       // .....
    }
}

Is this 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-28T03:07:44+00:00Added an answer on May 28, 2026 at 3:07 am

    Easiest way is to declare a find function in your class:

    function find(){
         return $this->db->find();
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Here's a Django model class I wrote. This class gets a keyerror when I
I want to write an app that takes in a model filename via cmd
My application has a plug-in model that allows third-party developers to write assemblies that
For some reason I'm not getting this. (Example model below) If I write: var
I'm not sure if this is a trivial questions but in a PHP class:
PHP's DateTime class has the two methods add() and sub() to add or subtract
this is a General Question about MVC .. I wrote a PHP Class that
This is my code: <?php require_once '../../../jq-config.php'; // include the jqGrid Class require_once ABSPATH.php/jqGrid.php;
I'm starting to write a simple Model class using codeigniter 2.1.0. All that I
I've been instructed to write a model strdup by creating a String struct on

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.