title: PHP catch fatal error and redirect
body: <p>Sometimes I get a fatal error in this line </p>
  
  <pre><code>$result = $db-&gt;execute($query);
  
  $primary = $result-&gt;getRows();
  </code></pre>
  
  <p><strong>Fatal error: Call to a member function getRows() on a non-object</strong> </p>
  
  <p>I'm searching for a solution to catch this error and redirect to index page.</p>
  
  <p>Rewriting something is complicated, because the system is old.</p>