replyHow did you send the screenshot and how did you operate it?
Also, doesn’t it say in the video that select and all return an array of model objects?
There are still several aspects to be discussed about this issue:
1. Since the data exists in the data attribute, how to determine the data attribute and remove the data set when traversing the object
2. This is just a Model object. If it is a Collection object, how is it implemented?
ArrayAccess should appear when these two problems arise. I will update it when I go back in the evening, so that you can truly understand the underlying operating mechanism of object traversal.
##The official manual blocks many details and directly explains the results The last question, why can the returned results be traversed?
Both the Model class and the Collection class implement the same ArrayAccess interface, so that they can be accessed like an array properties in the object.
replyBecause the returned result set is an object, the values of the internal attributes must be obtained through array traversal. The data attribute is the result set of the database query.
Let’s take an official screenshot first to confirm the correctness of my underlying source code analysis:
There are still several aspects to be discussed about this issue:
1. Since the data exists in the data attribute, how to determine the data attribute and remove the data set when traversing the object
2. This is just a Model object. If it is a Collection object, how is it implemented?
ArrayAccess should appear when these two problems arise. I will update it when I go back in the evening, so that you can truly understand the underlying operating mechanism of object traversal.
First read the official manual instructions:
Then look at the underlying source code:
##The official manual blocks many details and directly explains the results The last question, why can the returned results be traversed?Both the Model class and the Collection class implement the same ArrayAccess interface, so that they can be accessed like an array properties in the object.