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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T06:35:21+00:00 2026-06-03T06:35:21+00:00

I still have not been able to figure this out. How can we access

  • 0

I still have not been able to figure this out. How can we access a one class object in another class?

I am using the below code but I am getting and error:

class ListofRecord{
        var $db;
    function __construct(){
            $db = global $db;

    }
    function record(){
       $record = $this->db->SelectQuery("SELECT * FROM user order by UID ASC");
       return $record;
    }

}
  • 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-03T06:35:22+00:00Added an answer on June 3, 2026 at 6:35 am

    You need to refer to the global $db variable first and then use it in a statement. You also have a minor syntax error in your constructor. You forgot to use the $this keyword when referring your your $db property.

    function __construct(){
        global $db
        $this->db = $db;
    }
    

    It also is a better practice not to use global variables and instead pass any variables that you need as parameters to your method call. In this case it is your constructor:

    function __construct($db){
        $this->db = $db;
    }
    
    $list_of_record = ListofRecord($db);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This error is a nightmare, I have not been able to figure out why
I have been doing a lot of research trying to figure this out, but
My question is similar to this question . Though I have not been able
I have this array and I can't figure out how to dissect it and
I been having trouble trying to figure this out. When I think I have
I have been reading up on Cloud computing on here and still not getting
I have this problem again and again... and still have not a satisfactory answer...
I've read through the various posts on SO about this, but have still not
I've been trying to figure out the best way to model this entity, and
In android I can't figure out why this cursor is empty in htc wildfire.

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.