1. the paging function provided by Yii2ActiveDataProvider does not need to query the result when ActiveDataProvider is used in the list, in normal times, the id is converted into a name directly in columns of the GridView for convenience, but this method is used to view the debug... 1. the page feature of Yii2 ActiveDataProvider does not need to query the result when ActiveDataProvider is used in the list, in normal times, the id is converted into a name directly in columns of the GridView for convenience. However, when you view debug, the same statement is executed multiple times, which affects the efficiency. In terms of Yii2 usage specifications, isn't this true?
2. what should I do if I do not convert the id into a name in columns of the GridView? How can I convert an id to a name using a multi-table join query before uploading it to the GridView?
Reply content:
1. the page feature of Yii2 ActiveDataProvider does not need to query the result when ActiveDataProvider is used in the list, in normal times, the id is converted into a name directly in columns of the GridView for convenience. However, when you view debug, the same statement is executed multiple times, which affects the efficiency. In terms of Yii2 usage specifications, isn't this true?
2. what should I do if I do not convert the id into a name in columns of the GridView? How can I convert an id to a name using a multi-table join query before uploading it to the GridView?
The two methods are combined:
When constructing ActiveDataProvider, add with (), for example:
$query->with(['store'])->where(['name' => $something]);
In this way, the content of the store table is included in the result set without repeated queries. This should be a standard practice;
If memcache is enabled and the results are saved in the memory in advance, the pressure on the database can be effectively reduced.