1
0
Fork 0
mirror of https://github.com/KingDuckZ/dindexer.git synced 2024-11-25 00:53:43 +00:00

Accept c-string queries.

This commit is contained in:
King_DuckZ 2017-08-19 15:15:43 +01:00
parent e85a900974
commit 42d6ad0eac
2 changed files with 8 additions and 1 deletions

View file

@ -42,6 +42,7 @@ namespace pq {
void connect ( void ); void connect ( void );
void disconnect ( void ); void disconnect ( void );
ResultSet query ( const std::string& parQuery ); ResultSet query ( const std::string& parQuery );
ResultSet query ( const char* parQuery );
std::string escaped_literal ( const std::string& parString ); std::string escaped_literal ( const std::string& parString );
std::string escaped_literal ( boost::string_ref parString ); std::string escaped_literal ( boost::string_ref parString );

View file

@ -132,7 +132,13 @@ namespace pq {
} }
ResultSet Connection::query (const std::string& parQuery) { ResultSet Connection::query (const std::string& parQuery) {
ResultInfo info(PQexec(m_localData->connection, parQuery.c_str())); assert(not parQuery.empty());
return this->query(parQuery.c_str());
}
ResultSet Connection::query (const char* parQuery) {
assert(parQuery);
ResultInfo info(PQexec(m_localData->connection, parQuery));
if (not info.result) if (not info.result)
throw DatabaseException("Error running query", "Error allocating result object", __FILE__, __LINE__); throw DatabaseException("Error running query", "Error allocating result object", __FILE__, __LINE__);
const int ress = PQresultStatus(info.result.get()); const int ress = PQresultStatus(info.result.get());