Is there a way to perform error checking with $db->query?

When using the global database manager, is there a way to catch errors? Just in case.

Ideally I would like to check for errors here before sending success.

Thanks!

Parents Reply Children
  • Hello.

    It is a public endpoint with noLoginRequired = true due to not wanting to burden an external team with the annoyance of jugging refresh tokens or authenticating with a user and pass. The bean->save(); method does not work within  public hooks. It just crashes the hook without any logs in sugar. I could bypass this with the code below but this seems like more of a security risk than just doing a quick update with SQL, but I could be wrong.

    global $current_user;



    if (empty($current_user) || empty($current_user->id)) {

        $current_user = new User();

        $current_user->getSystemUser(); // or any other user bean

    }

    In any case, thank you for the reply.