mirror of
https://github.com/boostorg/mysql.git
synced 2026-01-28 19:32:10 +00:00
Lowered std requirement to C++11
This commit is contained in:
@@ -23,11 +23,18 @@
|
||||
void print_employee(const boost::mysql::row& employee)
|
||||
{
|
||||
std::cout << "Employee '"
|
||||
<< employee.values()[0] << " " // first_name (type std::string_view)
|
||||
<< employee.values()[1] << "' earns " // last_name (type std::string_view)
|
||||
<< employee.values()[0] << " " // first_name (type boost::string_view)
|
||||
<< employee.values()[1] << "' earns " // last_name (type boost::string_view)
|
||||
<< employee.values()[2] << " dollars yearly\n"; // salary (type double)
|
||||
}
|
||||
|
||||
#define ASSERT(expr) \
|
||||
if (!(expr)) \
|
||||
{ \
|
||||
std::cerr << "Assertion failed: " #expr << std::endl; \
|
||||
exit(1); \
|
||||
}
|
||||
|
||||
// UNIX sockets are only available in, er, UNIX systems. Typedefs for
|
||||
// UNIX socket-based connections are only available in UNIX systems.
|
||||
// Check for BOOST_ASIO_HAS_LOCAL_SOCKETS to know if UNIX socket
|
||||
@@ -85,14 +92,14 @@ void main_impl(int argc, char** argv)
|
||||
// resultset will have no fields and no rows
|
||||
sql = "UPDATE employee SET salary = 10000 WHERE first_name = 'Underpaid'";
|
||||
result = conn.query(sql);
|
||||
assert(result.fields().size() == 0); // fields() returns a vector containing metadata about the query fields
|
||||
ASSERT(result.fields().size() == 0); // fields() returns a vector containing metadata about the query fields
|
||||
|
||||
// Check we have updated our poor intern salary
|
||||
result = conn.query("SELECT salary FROM employee WHERE first_name = 'Underpaid'");
|
||||
auto rows = result.fetch_all();
|
||||
assert(rows.size() == 1);
|
||||
[[maybe_unused]] double salary = rows[0].values()[0].get<double>();
|
||||
assert(salary == 10000);
|
||||
ASSERT(rows.size() == 1);
|
||||
double salary = rows[0].values()[0].get<double>();
|
||||
ASSERT(salary == 10000);
|
||||
|
||||
// Notify the MySQL server we want to quit, then close the underlying connection.
|
||||
conn.close();
|
||||
|
||||
Reference in New Issue
Block a user