MCPcopy Create free account
hub / github.com/Apress/beginning-cpp20 / query

Method query

Exercises/Modules/Chapter 18/Soln18_03/DB.cpp:59–82  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

57}
58
59QueryResult* Database::query(const char* query)
60{
61 if (!hasConnection())
62 {
63 return nullptr;
64 }
65
66 // Our database only understands one single query!
67 if (std::strcmp(query, "SELECT * FROM CUSTOMER_TABEL") != 0)
68 {
69 return nullptr;
70 }
71
72 auto result{ std::make_unique<QueryResult>() };
73 result->data = std::vector<std::vector<const char*>>{
74 { "Sherlock", "Holmes", "Baker Street", "221", "London" },
75 { "Joe", "Biden", "Pennsylvania Avenue", "1600", "Washington DC" },
76 { "Donald", "Duck", "Webfoot Walk", "1313", "Duckville" },
77 { "Sirius", "Black", "Grimmauld Place", "12", "London" },
78 { "Nemo", "Clownfish", "Wallaby Way", "42", "Sydney" },
79 { "Sam", "Malone", "Beacon Street", "112", "Boston" }
80 };
81 return result.release();
82}
83
84int db_num_fields(DB_QUERY_RESULT* result)
85{

Callers 1

db_queryFunction · 0.45

Calls 1

releaseMethod · 0.80

Tested by

no test coverage detected