我正在尝试使用CGridView显示车辆模型。
为了显示Fld7465RRef引用列的值,需要执行以下sql select操作:
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
我找不到为该查询建立关系的解决方案。
发布于 2013-01-11 08:40:54
一种方法是使用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();
当然,您应该使用如下语句绑定参数(如果有):
$command->bindParam(":userID", $userID, PDO::PARAM_STR);
另一种方式是query-builder
https://stackoverflow.com/questions/14272438
复制相似问题