-
Notifications
You must be signed in to change notification settings - Fork 1
Working with the Database
Luke Pring edited this page Mar 19, 2025
·
12 revisions
To access data stored in the database, the VMSDatabase class.
An instance of this class is already initialised at the top of the main.cpp file. (VMSDatabase VMSDatabase;)
| Function Name | Example | Available |
|---|---|---|
| getData(table) | VMSDatabase.getData("pets"); |
✅ |
| printTable(table) | VMSDatabase.printTable("pets"); |
❌ |
| addRecord(table, data) | VMSDatabase.addRecord("pets", {"Bob", "Pug", "3", "Has asthma", "1", "1"}); |
❌ |
| deleteRecord(table, id) | VMSDatabase.deleteRecord("pets", "1") |
❌ |
The table parameter is made easy with a set of short options for each table. It is passed as a single word string.
-
pets- Pet Management -
owners- Owner Management -
appointments- Appointment Management -
staff- Staff Management
This function is used to retrieve data from the database.
The data is returned as a <vector>. A single value from the table can be referenced simply.
Example: std::cout << VMSDatabase.getData("pets")[0][1];
Explanation: Print the second value (Pet Name) from the first record in the Pet Management table.
Result: Bob
By Luke Pring and Jack Turner for the Software Development 2 module at University of Roehampton, London.