0

我正在尝试使用 CGridView 显示车辆模型。

为了显示 Fld7465RRef 引用列的值,需要以下 sql 选择:

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

我找不到为此查询建立关系的解决方案。

4

1 回答 1

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

于 2013-01-11T08:40:54.317 回答