drogon
C++14/17-based HTTP application framework
Loading...
Searching...
No Matches
drogon::orm::Result Class Reference

Result set containing data returned by a query or command. More...

#include <drogon/orm/Result.h>

Public Types

using DifferenceType = long
using SizeType = size_t
using Reference = Row
using ConstIterator = ConstResultIterator
using Iterator = ConstIterator
using RowSizeType = unsigned long
using FieldSizeType = unsigned long
using ConstReverseIterator = ConstReverseResultIterator
using ReverseIterator = ConstReverseIterator
using value_type = Row
using size_type = SizeType
using difference_type = DifferenceType
using reference = Reference
using const_reference = const Reference
using iterator = Iterator
using const_iterator = ConstIterator
using reverse_iterator = ConstReverseIterator
using const_reverse_iterator = ConstReverseIterator

Public Member Functions

 Result (ResultImplPtr ptr)
 Result (const Result &r) noexcept=default
 Result (Result &&) noexcept=default
Result & operator= (const Result &r) noexcept
Result & operator= (Result &&) noexcept
SizeType size () const noexcept
SizeType capacity () const noexcept
ConstIterator begin () const noexcept
ConstIterator cbegin () const noexcept
ConstIterator end () const noexcept
ConstIterator cend () const noexcept
ConstReverseIterator rbegin () const
ConstReverseIterator crbegin () const
ConstReverseIterator rend () const
ConstReverseIterator crend () const
bool empty () const noexcept
Reference front () const noexcept
Reference back () const noexcept
Reference operator[] (SizeType index) const noexcept
Reference at (SizeType index) const
void swap (Result &) noexcept
RowSizeType columns () const noexcept
 Number of columns in result.
const char * columnName (RowSizeType number) const
 Name of column with this number (throws exception if it doesn't exist).
SizeType affectedRows () const noexcept
unsigned long long insertId () const noexcept

Friends

class Field
class Row

Detailed Description

Result set containing data returned by a query or command.

This behaves as a container (as defined by the C++ standard library) and provides random access const iterators to iterate over its rows. A row can also be accessed by indexing a result R by the row's zero-based number:

for (Result::SizeType i=0; i < R.size(); ++i) Process(R[i]);

Result sets in libpqxx are lightweight, Reference-counted wrapper objects which are relatively small and cheap to copy. Think of a result object as a "smart pointer" to an underlying result set.

Member Function Documentation

◆ affectedRows()

SizeType drogon::orm::Result::affectedRows ( ) const
noexcept

If command was INSERT, UPDATE, or DELETE: number of affected rows

Returns
Number of affected rows if last command was INSERT, UPDATE, or DELETE; zero for all other commands.

◆ insertId()

unsigned long long drogon::orm::Result::insertId ( ) const
noexcept

For Mysql, Sqlite3 databases, return the auto-incrementing primary key after inserting For postgreSQL databases, this method always returns zero, One can use the following sql to get auto-incrementing id: insert into table_name volumn1, volumn2 values(....) returning id;


The documentation for this class was generated from the following file: