mirror of
https://github.com/boostorg/mysql.git
synced 2026-02-15 01:02:17 +00:00
Moved all names into namespace boost::mysql
This commit is contained in:
@@ -25,12 +25,12 @@ void main_impl(int argc, char** argv)
|
||||
}
|
||||
|
||||
// Connection params (host, port, user, password, database)
|
||||
boost::asio::ip::tcp::endpoint ep (boost::asio::ip::address_v4::loopback(), mysql::default_port);
|
||||
mysql::connection_params params (argv[1], argv[2], "mysql_asio_examples");
|
||||
boost::asio::ip::tcp::endpoint ep (boost::asio::ip::address_v4::loopback(), boost::mysql::default_port);
|
||||
boost::mysql::connection_params params (argv[1], argv[2], "mysql_asio_examples");
|
||||
|
||||
// TCP and MySQL level connect
|
||||
boost::asio::io_context ctx;
|
||||
mysql::tcp_connection conn (ctx);
|
||||
boost::mysql::tcp_connection conn (ctx);
|
||||
conn.next_level().connect(ep);
|
||||
conn.handshake(params);
|
||||
|
||||
@@ -40,7 +40,7 @@ void main_impl(int argc, char** argv)
|
||||
FROM employee emp
|
||||
JOIN company comp ON (comp.id = emp.company_id)
|
||||
)";
|
||||
mysql::tcp_resultset result = conn.query(sql);
|
||||
boost::mysql::tcp_resultset result = conn.query(sql);
|
||||
|
||||
/**
|
||||
* Resultsets allow you to access metadata about the fields in the query
|
||||
@@ -51,24 +51,24 @@ void main_impl(int argc, char** argv)
|
||||
*/
|
||||
assert(result.fields().size() == 2);
|
||||
|
||||
[[maybe_unused]] const mysql::field_metadata& company_name = result.fields()[0];
|
||||
[[maybe_unused]] const boost::mysql::field_metadata& company_name = result.fields()[0];
|
||||
assert(company_name.database() == "mysql_asio_examples"); // database name
|
||||
assert(company_name.table() == "comp"); // the alias we assigned to the table in the query
|
||||
assert(company_name.original_table() == "company"); // the original table name
|
||||
assert(company_name.field_name() == "company_name"); // the name of the field in the query
|
||||
assert(company_name.original_field_name() == "name"); // the name of the physical field in the table
|
||||
assert(company_name.type() == mysql::field_type::varchar); // we created the field as a VARCHAR
|
||||
assert(company_name.type() == boost::mysql::field_type::varchar); // we created the field as a VARCHAR
|
||||
assert(!company_name.is_primary_key()); // field is not a primary key
|
||||
assert(!company_name.is_auto_increment()); // field is not AUTO_INCREMENT
|
||||
assert(company_name.is_not_null()); // field may not be NULL
|
||||
|
||||
[[maybe_unused]] const mysql::field_metadata& employee_id = result.fields()[1];
|
||||
[[maybe_unused]] const boost::mysql::field_metadata& employee_id = result.fields()[1];
|
||||
assert(employee_id.database() == "mysql_asio_examples");// database name
|
||||
assert(employee_id.table() == "emp"); // the alias we assigned to the table in the query
|
||||
assert(employee_id.original_table() == "employee"); // the original table name
|
||||
assert(employee_id.field_name() == "employee_id"); // the name of the field in the query
|
||||
assert(employee_id.original_field_name() == "id"); // the name of the physical field in the table
|
||||
assert(employee_id.type() == mysql::field_type::int_); // we created the field as INT
|
||||
assert(employee_id.type() == boost::mysql::field_type::int_); // we created the field as INT
|
||||
assert(employee_id.is_primary_key()); // field is a primary key
|
||||
assert(employee_id.is_auto_increment()); // we declared the field as AUTO_INCREMENT
|
||||
assert(employee_id.is_not_null()); // field cannot be NULL
|
||||
|
||||
Reference in New Issue
Block a user