This is my problem:
To generate a report, I have one table and about 3 joined table. At least 2 tables have a large number of fields.
Student (40 fields)
School (10 fields)
Class (12 fields)
ZipCode (5 fields)
School has many classes
Classes has many student
Student has one ZipCode
In fact, I don’t need too many informations to my report. I’m trying to find my informations like this:
student::model()->with(array('school', 'class', 'zipcode'))->findAll();
Well, when a school have around 1000 students, PHP crashs with memory error. I realized that was because the joins and too many fields.
What I want to do:
Use criteria to define which fields I want to return from DB:
$criteria = new CDbCriteria(); $criteria->select = 'estudent_name, school.name, class.title'; student::model()->with(array('school', 'class', 'zipcode'))->findAll();
But this doesn’t work. Yii says it does not recognize ‘school.name’ or ‘class.title’.
- I already added aliases to the related tables.