I'm trying to reproduce something similiar to Djangos' Model class in PHP. I was wondering how django handles the loading and saving entries from a models' table.
For example, when calling Person.objects.all()
( Person
being a subclass of django.db.models.Model
of course), I expect Django to perform an SQL Query, SELECT * FROM myapp_person
, for instance, and then transforms the data recieved from the query to instances of the Model-class. Is this correct? Then,
Person.objects.filter(name="Paul")
I expect Django to perform an SQL Query like SELECT * FROM myapp_person WHERE name = 'Paul'
, but what if Person.objects.all()
was called before? Does django cache them or does it just perform the request for each call?
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.