0

I'm trying to display Vehicle model using CGridView.

In order to display value of Fld7465RRef reference column, following sql select is needed:

select VUF._Fld7468_S as Loading_Time_To_DLR  
FROM Vehicles as Vehicles  
left join (_InfoReg7464 as VUF                 
inner join _Chrc7246 as CFU
on VUF._Fld7467RRef = CFU._IDRRef                  
and CFU._Description ='Vehicle uploading for DLRTime')                 
on Vehicles._IDRRef =  VUF._Fld7465RRef

I can't find a solution to build a relation for this query.

tshepang
  • 12,111
  • 21
  • 91
  • 136

1 Answers1

2

One way to do it would be DAO:

$mySqlString = "
    select VUF._Fld7468_S as Loading_Time_To_DLR  
    FROM Vehicles as Vehicles  
    left join (_InfoReg7464 as VUF                 
    inner join _Chrc7246 as CFU
    on VUF._Fld7467RRef = CFU._IDRRef                  
    and CFU._Description ='Vehicle uploading for DLRTime')                 
    on Vehicles._IDRRef =  VUF._Fld7465RRef
";
$command = Yii::app()->db->createCommand($mySqlString); 
$aResult = $command->query()->readAll();

Of course, you should bind your parameters, if there are any, with a statement like this:

$command->bindParam(":userID", $userID, PDO::PARAM_STR);

The other way is query-builder

Ivo Renkema
  • 2,188
  • 1
  • 29
  • 40