Added detailed view

develop
tastytea 2018-08-30 14:30:44 +02:00
parent c67f973227
commit 05c601021d
No known key found for this signature in database
GPG Key ID: CFC39497F1B26E07
2 changed files with 72 additions and 64 deletions

View File

@ -1,6 +1,6 @@
cmake_minimum_required (VERSION 3.7) cmake_minimum_required (VERSION 3.7)
project (whyblocked project (whyblocked
VERSION 0.1.0 VERSION 0.2.0
LANGUAGES CXX LANGUAGES CXX
) )

View File

@ -46,10 +46,13 @@ int main(int argc, char *argv[])
{ {
sqlite::connection con(get_filepath()); sqlite::connection con(get_filepath());
string answer; string answer;
bool keeprunning = true;
cout << "Would you like to add, remove or view records?\n"; cout << "This is whyblock " << global::version << ".\n";
cout << "Or do you want to get the details of a record?\n"; cout << "Type add, remove, view or details. Or just the first letter.\n";
cout << "Type add, remove, view or details. Or just the first letter\n"; cout << "Type quit or q to quit the program.\n";
while (keeprunning)
{
cout << ": "; cout << ": ";
cin >> answer; cin >> answer;
switch (answer[0]) switch (answer[0])
@ -94,9 +97,8 @@ int main(int argc, char *argv[])
{ {
sqlite::query q(con, "SELECT * FROM blocks WHERE user = \'" + answer + "\';"); sqlite::query q(con, "SELECT * FROM blocks WHERE user = \'" + answer + "\';");
boost::shared_ptr<sqlite::result> result = q.get_result(); boost::shared_ptr<sqlite::result> result = q.get_result();
result->next_row();
cout << answer << " is "; cout << answer << " is ";
if (result->get_row_count() == 0) if (!result->next_row())
{ {
cout << "not in the database.\n"; cout << "not in the database.\n";
break; break;
@ -112,18 +114,24 @@ int main(int argc, char *argv[])
cout << result->get_string(2) << '\n'; cout << result->get_string(2) << '\n';
} }
{ {
cout << "Receipts:\n";
sqlite::query q(con, "SELECT * FROM urls WHERE user = \'" + answer + "\';"); sqlite::query q(con, "SELECT * FROM urls WHERE user = \'" + answer + "\';");
boost::shared_ptr<sqlite::result> result = q.get_result(); boost::shared_ptr<sqlite::result> result = q.get_result();
while(result->next_row()) while(result->next_row())
{ {
cout << result->get_string(1) << '\n'; cout << " " << result->get_string(1) << '\n';
} }
} }
break; break;
case 'q':
case 'Q':
keeprunning = false;
break;
} }
default: default:
cout << "Response not understood.\n"; cout << "Response not understood.\n";
} }
}
// sqlite::execute ins(con, "INSERT INTO TEST VALUES(?, ?, ?);"); // sqlite::execute ins(con, "INSERT INTO TEST VALUES(?, ?, ?);");
// ins % sqlite::nil % "Hello"; // ins % sqlite::nil % "Hello";
// ins(); // ins();