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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T20:35:16+00:00 2026-05-26T20:35:16+00:00

After spending half an hour to find a proper, self-explaining title for this question,

  • 0

After spending half an hour to find a proper, self-explaining title for this question, I finally gave up. Apologies for it, I’m not a native English speaker.

Anyways, the question is about using a particular class to be extended multiple times – not multiple inheritance. So, imagine two repository classes called from the same function:

public function someFunction() 
{
   $qp = QuestionRepository();
   $cp = CommentRepository();
} 

and the QuestionRepository is like:

class QuestionRepository extends PDO 
{
    public function __construct()
    {
        parent::__construct();
    }
}

the CommentRepository is like:

class CommentRepository extends PDO 
{
    public function __construct()
    {
        parent::__construct();
    }
}

whereas the PDO class is like this:

class PDO 
{
    public function __construct() 
    {
        $pdo = new PDO(...);
    } 
}

So basically, the PDO class is extended twice, therefore two instances of PDO is initiated. However, the question is whether this means 2 different connections to mysql – which would result in performance decrease or the pdo recognizes that there is an alive connection therefore it just ignores the second instance?

  • 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-26T20:35:17+00:00Added an answer on May 26, 2026 at 8:35 pm

    You could declare a “static” field in PDO for the mysql connection. That way the same field will be used in each instance, regardless of which subclass is responsible for the instantiation.

    It also requires that you access the field statically; PDO::$mysql_link;

    If you declare the field without specifying visibility it will be public, meaning you’ll be able to refer to the same field from anywhere as long as PDO is defined.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

EDIT: After spending several hours researching this, I don't think I'm going to find
I am new to this after spending 2 days trying to find an answer
After spending a good 3 to 4 hours on google trying to find any
After spending SEVERAL frustrated hours on this I am asking for your help. I
I almost didn't dare to ask this question because it looks trivial but after
After spending a not-insignificant amount of time converting a page that used concatenated html,
After spending 14 hours on this I think its time to share my woes
This is my first time using IB, but after spending a one or two
After spending some hours with the Ruby Debugger I finally learned that I need
So, after spending a couple of hours of manually configuring autotools, I finally managed

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.