In my project, I am using mvc pattern. I do no know which class operate database operations. That's I am doing database operations in Model class, but I do not know this is correct. I have confused. Controller class maybe can be correct place insertion, deletion, update oparations. However, I do not know exactly where I have to do database operations. Also I want to search a value in database. Is model class convenient for these operations ? Thanks,
You should learn more about MVC architecture. As stated on Wikipedia
The model manages the behavior and data of the application domain, responds to requests for information about its state (usually from the view), and responds to instructions to change state (usually from the controller). In event-driven systems, the model notifies observers (usually views) when the information changes so that they can react.
The view renders the model into a form suitable for interaction, typically a user interface element. Multiple views can exist for a single model for different purposes. A viewport typically has a one to one correspondence with a display surface and knows how to render to it.
The controller receives user input and initiates a response by making calls on model objects. A controller accepts input from the user and instructs the model and viewport to perform actions based on that input.
Controller class maybe can be correct place insertion, deletion, update oparations.
No. You should do logic in Model. Controller are only used to call that functionalities.
Also I want to search a value in database. Is model class convenient for these operations ?
You should do it in Model.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With