According to this PHP documentation on mysqli::prepare(), it appears that the return value should be a statement object or false.
In the example below, I made a mistake in changing an INSERT INTO to a REPLACE INTO, and the error-handler code never executed but the catch picked up a 1064 error.
Is this the expected behavior?  Why didn't $db->prepare($sql) return false?  Does using try/catch pick up the error before the return?
Thank you.
try {
  $sql = " INSERT REPLACE INTO ... WHERE id=?";
  if ( !($stmt = $db->prepare($sql) ) ) {
    /* error handler code */
  }
} catch ( Exception $err ) {
  $res['r'] = $err->getCode();
  $res['m'] = $err->getMessage();
}
 
 
    