When it comes to OOP where an external database is being read from and written to, is it necessary to have attributes/properties within the objects to store the data? Or is it enough to simply read from the database, display it immediately, and later on directly insert any posted data back into it?
If it is necessary to have fields within the objects to store data, how/when would you read from or write to the database and update these fields?
I understand the concept of OOP and how an object should represent an entity (a thing, such as a user), but when it comes to web development, databases, and OOP I'm not sure I entirely understand how it's meant to work together.
In the past, the way I've managed this is by having objects with CRUD methods, accepting data from the view, and passing data to the controller to be interpreted for display.
I've looked at posts such as the following, but it doesn't seem to clear anything up for me: Do objects in OOP have to represent an entity?
I've also tried looking for 'OOP when working with a database' tutorials but only get tutorials showing how to create a database object and nothing that helps me understand better.
I have also seen ORM mentioned a lot as a solution of mapping a database to an object, but I still have trouble understanding exactly why you need to store the data in an object as opposed to simply displaying or storing it immediately.