findallbysql() is very nice when doing complex queries but the result set is always limited to the fields defined in the model class.
This query:
Incident::model->findAllBySql('
select
Person.firstname,Person.LastName,Func.Icon,Func.Name
from
Func,PersonFunc,Person,PersonIncident
where
Func.id = PersonFunc.FuncId
and
PersonFunc.personDn=Person.dn
and
Person.id=PersonIncident.personId
and
PersonIncident.IncidentId = :incidentId',array('incidentId'=>$incidentId));
does not retrieve any data because all filelds in the select are unknown in the Incident Data Model and are discarded depp inside of activerecord.
Adding relations and using with() does solve this problem but is far away from beeing intuitive.
It would be great to have a Method Yii::app()->findallBySQL() (or something similar) that s not bound to a specific model and does return the fields in the 'from' section of a sql statement.
I know, this has nothing to do with 'pure'-Activerecord Religion but to be honest, for me it is much easier to create a sql-statement than to transfer what I want into real activerecord requests.
Btw, how would this select look like in 'pure' activerecord ?
Thank you,
MiR