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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T04:12:38+00:00 2026-06-18T04:12:38+00:00

I currently have a class called Connect with the following code: class Connect {

  • 0

I currently have a class called Connect with the following code:

class Connect
{
public $sqlHost='host';
public $sqlUser='user';
public $sqlPass='pass';
public $sqlDB='db';

public $db;
    public function __construct() {
        $this->db = new mysqli($this->sqlHost, $this->sqlUser, $this->sqlPass, $this>sqlDB);
    }
}
?>

I also have a class called TODO and I was wondering, how could I go about calling $db located in the Connect class from the TODO class?

  • 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-18T04:12:39+00:00Added an answer on June 18, 2026 at 4:12 am

    imagine you have have two objects called

    $connect = new Connect();
    $todo = new TODO();
    

    now 1 of 3 things can happen, You can pass the $connect object into a method of $todo or if a Connect object is a member of a TODO object, or create a new connect object.

    scenario 1:

    class TODO {
        public function foo($connect){
            // You can get the db object here:
            $connect->db
        }
    }
    
    $todo->foo($connect)
    

    scenario 2:

    class TODO {
        public $connect;
        public function __construct(){
            $this->connect=new Connect(); 
        }
        public function foo(){
            //get db:
            $this->connect->db;
        }
    }
    $todo->foo();
    

    scenario 3:

    class TODO {
        public function foo(){
            $connect = new Connect();
            $connect->db;
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following code: public class MyLocationListener implements LocationListener { @Override public void
Currently I have a class called user that I want to create with different
I'm working on a forum software currently. I have a class called User, within
I currently have a class called clientActivity that contains a finger paintig activity that
I'm currently working on an OO PHP application. I have a class called validation
I currently have a class file with the following enumeration: using System; namespace Helper
I currently have a class where I need accomplish the equivalent of the following
Currently I have a class that looks like this: public class MyClass : IMyClass
I currently have a class called TextureObject. In the creation function I create the
I currently have a class called Polynomial, The initialization looks like this: def __init__(self,

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.