?? fieldinf1.cc
字號:
#include <iostream>#include <iomanip>#include <mysqlcppapi/mysqlcppapi.h>int main() { try { // its in one big try block mysqlcppapi::Connection con; con.connect(); con.select_database("mysql_cpp_data"); mysqlcppapi::Query query = con.create_Query(); query << "select * from stock" << std::ends; mysqlcppapi::Result_Store res = query.store(); std::cout << "Query: " << query.preview() << std::endl; std::cout << "Records Found: " << res.size() << std::endl << std::endl; std::cout << "Query Info:\n"; std::cout.setf(std::ios::left); const mysqlcppapi::Fields& fields = res.get_fields(); for (unsigned int i = 0; i < fields.size(); i++) { const mysqlcppapi::FieldInfo& field = fields[i]; std::cout << std::setw(2) << i << std::setw(15) << field.get_Name().c_str() // this is the name of the field //<< setw(15) << field.get_FieldType().sql_name() // this is the SQL identifier name // Result::types(unsigned int) returns a mysql_type_info which in many // ways is like type_info except that it has additional sql type // information in it. (with one of the methods being sql_name()) //<< setw(20) << field.get_FieldType().get_Name() // this is the C++ identifier name which most closely resembles // the sql name (its is implementation defined and often not very readable) << std::endl; } std::cout << std::endl; return 0; } catch (mysqlcppapi::ex_BadQuery& er) { std::cerr << "Error: " << er.what() << std::endl; return -1; } catch (mysqlcppapi::ex_BadConversion& er) { // handle bad conversions std::cerr << "Error: Tried to convert \"" << er.get_Data() << "\" to a \"" << er.get_TypeName() << "\"." << std::endl; return -1; }}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -