Database layer now support automatic type conversion and the Result has iterator support.

This also means you can use for each to loop through a result.
This commit is contained in:
Eelke Klein 2017-01-25 06:50:57 +01:00
parent 6e852f466f
commit 56fbd20635
2 changed files with 155 additions and 24 deletions

View file

@ -46,6 +46,26 @@ ErrorDetails ErrorDetails::createErrorDetailsFromPGresult(const PGresult *result
return r;
}
bool Row::next()
{
if (m_row < m_result.getRows()) {
++m_row;
return true;
}
return false;
}
Value Row::get(int col) const
{
return m_result.get(col, m_row);
}
//Value Row::get(const char *colname) const
//{
//}
Result::Result(PGresult *res)
: result(res)
{
@ -165,6 +185,14 @@ const char * Result::getVal(int col, int row) const
return PQgetvalue(result, row, col);
}
Value Result::get(int col, int row) const
{
return Value(
PQgetvalue(result, row, col),
PQftype(result, col)
);
}
Oid Result::type(int col) const
{
return PQftype(result, col);