fastcgi++
A C++ FastCGI/Web API
results.cpp
Go to the documentation of this file.
1 
10 /*******************************************************************************
11 * Copyright (C) 2017 Eddie Carle [eddie@isatec.ca] *
12 * *
13 * This file is part of fastcgi++. *
14 * *
15 * fastcgi++ is free software: you can redistribute it and/or modify it under *
16 * the terms of the GNU Lesser General Public License as published by the Free *
17 * Software Foundation, either version 3 of the License, or (at your option) *
18 * any later version. *
19 * *
20 * fastcgi++ is distributed in the hope that it will be useful, but WITHOUT ANY *
21 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS *
22 * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for *
23 * more details. *
24 * *
25 * You should have received a copy of the GNU Lesser General Public License *
26 * along with fastcgi++. If not, see <http://www.gnu.org/licenses/>. *
27 *******************************************************************************/
28 
29 #include "fastcgi++/sql/results.hpp"
30 
31 Fastcgipp::SQL::Status Fastcgipp::SQL::Results_base::status() const
32 {
33  if(m_res == nullptr)
34  return Status::noResult;
35 
36  switch(PQresultStatus(m_res))
37  {
38  case PGRES_EMPTY_QUERY:
39  return Status::emptyQuery;
40  case PGRES_COMMAND_OK:
41  return Status::commandOk;
42  case PGRES_TUPLES_OK:
43  return Status::rowsOk;
44  case PGRES_COPY_OUT:
45  return Status::copyOut;
46  case PGRES_COPY_IN:
47  return Status::copyIn;
48  case PGRES_BAD_RESPONSE:
49  return Status::badResponse;
50  case PGRES_NONFATAL_ERROR:
51  return Status::nonfatalError;
52  case PGRES_COPY_BOTH:
53  return Status::copyBoth;
54  case PGRES_SINGLE_TUPLE:
55  return Status::singleTuple;
56  default:
57  return Status::fatalError;
58  };
59 }