使用cakephp 2中的find('all')在4个表之间进行联接,并附加带有if else条件的字段

时间:2018-08-30 13:14:47

标签: cakephp-2.1

如何编写以下代码:

- run: bundle install && bundle clean

采用if(!empty($event)) $msg = " and LogEvent='".$event."'"; else $msg =""; if(!empty($user)) $k = " and UserName='".$user."'"; else $k =""; $sql="select UserName,CONVERT_TZ(EventTime,'+00:00','+5:30') as EventTime,EventName,CarrierName,TrunkGroupName,A.Description as Description from Nextone_cdr_config.UserLogs A, Nextone_cdr_config.Carriers C, Nextone_cdr_config.TrunkGroups T, Nextone_cdr_config.UserEvent B where CarrierId=A.FK_CarrierId and TrunkGroupId=FK_TrunkGroupId and B.Id=LogEvent ".$msg.$k. " and date(EventTime)>='".$date."' and Date(EventTime)<='".$date1."'; "; 格式,无论将查询放置在何处,模型的名称(在cakephp2中应为表名)应该是什么?

0 个答案:

没有答案