title: How to check the connection to MySQL database with RedBean?
body: <p>How do I programmatically find out if there was an error connecting to the database via <code>R::setup()</code> in RedBean?</p>
  
  <p>The object that is returned by this:</p>
  
  <pre><code>$ret = R::setup('mysql:host=127.0.0.1;dbname=testdatabase', 'root', '');
  </code></pre>
  
  <p>is the same as the object that is returned by this:</p>
  
  <pre><code>$ret = R::setup('mysql:host=127.0.0.1BADBADBAD;dbname=testdatabase', 'root', '');
  </code></pre>
  
  <p>And when I try to access the database, it gives a PHP error and stops execution so I can't check the value of <code>$bean</code>.</p>
  
  <pre><code>$bean = R::findOne('uploadedfiles',' filename = "ok" ');
  </code></pre>
  
  <p>And so a try/catch is also not possible because RedBean does not through a proper error that can be caught.</p>
  
  <p>How can I check if the connection created in <code>R::setup()</code> was successful or not programmatically? </p>