title: How to fix Message: SQLSTATE[08004] [1040] Too many connections
body: <p>I am using below code for database connection </p>
  
  <pre><code>class Database extends PDO{
  
      function __construct(){
  
          try {
              parent::__construct(DB_TYPE.':host='.DB_HOST.';dbname='.DB_NAME,DB_USER,DB_PASS);
              $this-&gt;setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
              $this-&gt;setAttribute(PDO::MYSQL_ATTR_INIT_COMMAND, "SET NAMES 'utf8'");
          } catch(PDOException $e){
              Logger::newMessage($e);
              logger::customErrorMsg();
          }
  
      }
  }
  </code></pre>
  
  <p>every thing like login , fetching data was working fine . Now suddenly I am having a exception error message </p>
  
  <pre><code>Message: SQLSTATE[08004] [1040] Too many connections
  
  Code: 1040
  </code></pre>
  
  <p>How to fix this error ?</p>
  
  <p>I have a model class there I am creating new database. </p>
  
  <pre><code> class Model {
  
  protected $_db;
  
  public function __construct(){
      //connect to PDO here.
      $this-&gt;_db = new Database();
      }
    }
  </code></pre>
  
  <p>and every model I make , I am extending from model class. </p>