title: PDO Classes across multiple websites
body: <p>I have written PDO classes with DB connection for a single website but what I actually need to use the same class across multiple websites. </p>
  
  <p><strong>The idea is that when I change something in the class the changes will reflect in all my website not just one but these 2 websites will still use 2 separate DBs</strong></p>
  
  <p>Could you please advice me on how to solve my problem or where should I start looking</p>
  
  <p>e.g.</p>
  
  <pre><code>core\ classes \ product.class.php
  
  Web_1 
  -databass.class.php for Web_1 using the core\classes\
  
  Web_2
  -databass.class.php for Web_2 using the core\classes\
  </code></pre>
  
  <hr>
  
  <p>This is my part of my code</p>
  
  <p><strong>File dbConfig.php</strong></p>
  
  <pre><code>&lt;?php 
  define('DB_TYPE', 'mysql');
  define('USER_NAME', 'test');
  define('USER_PASSWORD', '********');
  define('HOSTNAME', 'localhost');
  define('DB_NAME', 'test_db');?&gt;
  </code></pre>
  
  <p><strong>File databass.class.php</strong></p>
  
  <pre><code>&lt;?php
  include_once($_SERVER['DOCUMENT_ROOT'] . 'dbConfig.php');
  class DatabasePDO
  {
      private static $_instance = array();
      static function getInstance ($dbName = DB_NAME)
      {
          if (! array_key_exists($dbName, self::$_instance)) {
              $dsn = DB_TYPE . ":host=" . HOSTNAME . ";dbname=" . $dbName;
              try {
                  self::$_instance[$dbName] = new PDO($dsn, USER_NAME, USER_PASSWORD);
                  self::$_instance[$dbName]-&gt;setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
              } catch (PDOException $e) {
                  echo "echo "Error!: " . $e-&gt;getMessage();
                  die();
              }
          }
          return self::$_instance[$dbName];
      }
  }?&gt;
  </code></pre>
  
  <p><strong>File product.class.php</strong></p>
  
  <pre><code>&lt;?php
  require_once "databass.class.php";
  
  class products_CLS
  {
      private $pid = null;
      private $title  = '';
  
      private static $dbConn = null;
  
      public function __construct ()
      {
          self::initializeConnection();
      }
  
      private static function initializeConnection ()
      {
          if (is_null(self::$dbConn)) {
              self::$dbConn = DatabasePDO::getInstance();
          }
      }
  
      /**
       * @return the $productid
       */
      public function getProductId()
      {
          return $this-&gt;pid;
      }   
  
      /**
       * @return the $producttitle
       */
      public function getProductTitle()
      {
          return $this-&gt;title;
      }
  }?&gt;
  </code></pre>