Ok I didn’t understand…
I’m still newbie at this…
I’m trying to use Flexigrid instead, but got the same problem.
Now it only shows a table with different projects, and FULL JOIN shows a table with multiple projects with same name because of the different hours for same project
What can I do?
This is what I use for Flexigrid atm, an echo in JSON:
public function actionPostxml()
{
if (isset($_POST['page'])) {
$page = $_POST['page'];
}
if (isset($_POST['sortname'])) {
$sortname = $_POST['sortname'];
}
if (isset($_POST['sortorder'])) {
$sortorder = $_POST['sortorder'];
}
if (isset($_POST['qtype'])) {
$table = "";
$qtype = $_POST['qtype'];
}
if (isset($_POST['query'])) {
$query = $_POST['query'];
}
if (isset($_POST['rp'])) {
$rp = $_POST['rp'];
}
$total=0;
$data = array();
$data['page'] = $_POST['page'];
$data['total'] = $total;
$data['rows'] = array();
$searchSql = ($qtype != '' && $query != '') ? $qtype.' LIKE \'%'.$query.'%\'' : '';
$model = Project::model()->with(array('ph','sales'))->findAll(array('limit'=>$_POST['rp'],'order'=>$sortname.' '.$sortorder));
foreach ($model as $m)
{
$data['rows'][]=array('id' => $m->id, 'cell' => array($m->name,$m->projectHours->hours,$m->sales->id));
$total++;
}
$data['total'] = $total;
echo json_encode($data);
}
And the relations in the Project model:
public function relations() {
return array(
'pidpid' => array(self::BELONGS_TO, 'Project', 'pid'),
'projectIdi' => array(self::HAS_ONE, 'ProjectIdi', 'id_project'),
'projectD' => array(self::HAS_ONE, 'ProjectD', 'id_project'),
'project' => array(self::HAS_ONE, 'ProjectId', 'id_project'),
'idCustomer' => array(self::BELONGS_TO, 'Customer', 'id_customer'),
'idArea' => array(self::BELONGS_TO, 'ProjectArea', 'id_area'),
'idUser' => array(self::BELONGS_TO, 'User', 'id_user'),
'projectProgress' => array(self::HAS_ONE, 'ProjectProgress', 'id'),
'projectHours' => array(self::HAS_ONE, 'ProjectHours', 'id_project'),
'ph' => array(self::HAS_MANY, 'ProjectHours', 'id_project','joinType'=>'FULL JOIN'),
'sales' => array(self::HAS_MANY, 'SalesOrder', 'id_project','joinType'=>'FULL JOIN'),
);
}