Using a database class in my user class

前端 未结 6 613
慢半拍i
慢半拍i 2021-02-09 01:00

In my project I have a database class that I use to handle all the MySQL stuff. It connects to a database, runs queries, catches errors and closes the connection.

Now I

6条回答
  •  梦毁少年i
    2021-02-09 01:36

    Since you are using the database as an object, why not just add methods to the object that your "users class" can employ to take care of the things it needs to do. The users class can contain a pointer to the database class. The database class will protect your database, and assure that the users class is using it appropriately.

提交回复
热议问题