so i am trying to get data into a cActiveDataProvider. I need to do a complicated join that joins 3 tables. I think i can get a solution using the following method.
$data = Yii::app()->db->createCommand()
->select("$usertableselectstring".", $branchAddrTableSelectArray".", $useraddrtableselectstring".", u.repid") ->from('users u') ->innerJoin('') ->innerJoin('') ->where("'") ->queryAll();
However, I am trying to do this using criteria. somewhat like this:
$criteria = new CDbCriteria(array(‘with’=>array(‘cUSTOMER’,‘cUSTORDERLINEs’), ‘order’=>‘t.ID, t.SALESREP_ID’));
Here is the issue. I have 3 tables. reps, orderlines, and orders.The join needs to be something like the following.
select year, week, repid, name, sum(orderQty) as qty
from reps r
inner join orders o on r.id = o.salesrep_id
inner join orderlines ol on o.id = ol.custOrderId
where o.status <> "H"
and o.user_10 = "1"
group by( year, week, repid, name);
The above is pseudocode for how i would do it in mysql. Putting that into a criteria statement is proving rather difficult. Thanks in advance for the help.