Hi,
I want to be able to search and sort in gridView using fields from related tables. I found these instructions:
http://www.yiiframework.com/wiki/653/displaying-sorting-and-filtering-model-relations-on-a-gridview/
I was able to use that information to create a working test program. When I use the debugger to view the underlying SQL, it appears that the same tables are being queried twice: once through the join to do the filtering and sorting and a second time through the relationship to display the city and country names:
[sql]SELECT SELECT tour
.* FROM tour
LEFT JOIN city
ON tour
.city_id
= city
.id
LEFT JOIN country
ON tour
.country_id
= country
.id
SELECT SELECT * FROM country
WHERE id
=1
SELECT SELECT * FROM city
WHERE id
=1[/sql]
Is there a way in gridView to request the city and country name columns from the first query that joins all the tables together, instead of using the model relationship which loads that information from subsequent queries? This would prevent the addition queries against the same tables.
Thanks!