title: Passing same PDO object to different classes
body: <p>I have classes like this:</p>
  
  <p>classPages.php</p>
  
  <pre><code>class pages {
  
      private $dbh;
  
      function __construct($dbh) { 
          $this-&gt;dbh = $dbh;
      }
      //...
  }
  </code></pre>
  
  <p>classNews.php</p>
  
  <pre><code>class news {
  
      private $dbh;
  
      function __construct($dbh) { 
          $this-&gt;dbh = $dbh;
      }
      //...
  }
  </code></pre>
  
  <p>classMod.php</p>
  
  <pre><code>class mod {
  
      private $dbh;
  
      function __construct($dbh) { 
          $this-&gt;dbh = $dbh;
      }
      //...
  }
  </code></pre>
  
  <p>And in index page:</p>
  
  <pre><code>try
  {
      $dbh = new PDO("mysql:host={$host};dbname={$dbname};charset=utf8", $username, $password, $options);
  }
  catch(PDOException $ex)
  {
      die("Failed to connect to the database: " . $ex-&gt;getMessage());
  }
  
  require 'classPages.php';
  require 'classNews.php';
  require 'classMod.php';
  
  $pages = new pages($dbh);
  $news = new news($dbh);
  $mod = new mod($dbh);
  
  //use above objects where needed
  </code></pre>
  
  <p>So i create single PDO object. Then pass it to the constructors of each classes. Then i use these objects and calls it's member functions which does fetching and insertion of data using this pdo object passed to constructor.</p>
  
  <p>Is it correct way? Or any conflicts directly/indirectly happen?</p>