/** * method Delete() * Delete a record */ function Delete($param) { try { $key = $param['key']; // get the parameter $key TTransaction::open('saciq'); // open a transaction with database $object = new Campus($key, FALSE); // instantiates the Active Record $object->delete(); // deletes the object from the database TTransaction::close(); // close the transaction $this->onReload($param); // reload the listing new TMessage('info', 'Registro excluído'); // success message } catch (Exception $e) { if ($e->getCode() == 23000) { new TMessage('error', '<b>Registro duplicado</b><br>Verifique os campos inseridos e tente novamente'); } else { if ($e->getCode() == 0) { new TMessage('error', '<b>Error</b> <br>' . $e->getMessage()); } else { new TMessage('error', '<b>Error Desconhecido</b> <br>Código: ' . $e->getCode()); } } // desfazer todas as operacoes pendentes TTransaction::rollback(); } }