Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void insertEmployee(MYSQL* conn, Employee const& emp)
- {
- if (conn != nullptr)
- {
- std::string fmt = "INSERT INTO employees(employeeNumber, lastName, firstName, extension, email, officeCode, reportsTo, jobTitle) "
- "VALUES (%d, \"%s\", \"%s\", \"%s\", \"%s\", \"%s\", %s, \"%s\")";
- std::vector<char> v(2000);
- sprintf(&v[0], v.size(), fmt,
- emp.empNum,
- emp.lastName,
- emp.firstName,
- emp.extension,
- emp.email,
- "1",
- emp.reportsTo,
- emp.jobTitle
- );
- if (mysql_query(conn, const_cast<char const*>(v.data())) == 0)
- std::cout << "Employee successfully added, check to verify by checking the number of the employee from the main menu, or using your DBMS application" << std::endl;
- else
- std::cout << "Error occurred: " << mysql_errno(conn) << " " << mysql_error(conn) << std::endl;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement