-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathIsCustomer.cpp
More file actions
69 lines (61 loc) · 1.77 KB
/
Copy pathIsCustomer.cpp
File metadata and controls
69 lines (61 loc) · 1.77 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#include <stdlib.h>
#include <iostream>
#include <driver.h>
#include <exception.h>
#include <resultset.h>
#include <statement.h>
#include <vector>
#include "Database.h"
#include <prepared_statement.h>
#include "Customer.h"
using namespace sql;
using namespace std;
/**
* @brief This class checks if the customer is a customer in the database
*
* @param msg The message to be sent to the emails
* @author Abdulrahim Hamed (ahamed4)
* @author Braikhna Yousafzai (byousafz)
* @author Colin Stoddart (cstodda6)
* @author Evangelos Makris (emakris2)
* @author Jem Parlakyigit (mparlaky)
*/
class IsCustomer:public Database {
public:
/**
* @brief Creates a connection to the database
*
* @see Database::Database(string serverName, string userName, string password);
*/
IsCustomer():Database("sql9.freemysqlhosting.net", "sql9372596", "fNf8Kr8wZD"){}
/**
* @brief Searches for the number of customers with that username
*
* @param username A string version of the username
* @returns The Int corresponding to the number of customers with that ID
*/
int searchCustomer(string username){
this->stmt = con->createStatement();
this->res = stmt->executeQuery("SELECT * FROM tbl_customers WHERE customer_userName ='" + username+"'");
return this->res->rowsCount();
delete this->stmt;
delete this->res;
}
/**
* @brief Searches for the number of customers with that ID
*
* @param id An Int version of the ID
* @returns The Int corresponding to the number of customers with that ID, which should be 1
*/
int searchCustomer(int id){
this->stmt = con->createStatement();
this->res = stmt->executeQuery("SELECT * FROM tbl_customers WHERE customer_id ='" + to_string(id) +"'");
return this->res->rowsCount();
delete this->stmt;
delete this->res;
}
~IsCustomer(){
delete this->stmt;
delete this->res;
}
};