Hi
Recently I used findAllbySql but I have two questions
MyModel::model()->findAllbySql("SELECT * FROM MyModel_table WHERE...");
Why have to use both MyModel and MyModel_table (in query) ?
Is not statement MyModel:: … agile enough to include the part of query FROM MyModel_table ? What happens if (FROM MyModel_table) not included?
I thing this is surplus, is there specific reason to implemented findAllbySql and findbySql like that ?
2)According to above
MyModel::model()->with('relatedModel')->findAllbySql("SELECT * FROM MyModel_table LEFT JOIN relatedModel_table WHERE...")
needs JOIN relatedModel_table to works
I know with(’…’) used to load also the relation model, but I refer because
MyModel::model()->with(‘relatedModel’)->findAll(‘t.attr>10 AND relatedModel.arr2<20’); works fine.
So, is there surplus too ?
Many thanks