Exemplo n.º 1
0
int64_t PDOPgSqlConnection::doer(const String& sql){
  testConnection();

  const char* query = sql.data();

  PQ::Result res = m_server->exec(query);

  if(!res){
    // I think this error should be handled in a different way perhaps?
    handleError(nullptr, "XX000", "Invalid result data");
    return -1;
  }

  ExecStatusType status = m_lastExec = res.status();

  int64_t ret;

  if(status == PGRES_COMMAND_OK){
    ret = (int64_t)res.cmdTuples();
  } else if(status == PGRES_TUPLES_OK) {
    ret = 0L;
  } else {
    HANDLE_ERROR(nullptr, res);
    return -1L;
  }

  this->pgoid = res.oidValue();

  return ret;
}