程式碼
SQL語句為
SELECT crsIpint
,crsIpout
,crsName
#,wfdz
,CheckStatus
,0 AS flag FROM vehicle.crossing AS t1 LEFT JOIN ( SELECT * FROM caminfo.devs_ip_status WHERE type
= 95 ) AS t2 ON( t1.crsId = t2 .DeviceID ) WHERE t1.type <> 0 LIMIT 0,20 UNION ( SELECT ip AS crsIpint,"" AS crsIpout,name AS crsName,"主伺服器" AS wfdz,1 AS CheckStatus,1 AS flag FROM crsName,"主伺服器" AS wfdz,1 AS CheckStatus,1 AS flag FROM crsName WHERE type
= 101 )
我想要的是
SELECT crsIpint
,crsIpout
,crsName
,wfdz
,CheckStatus
,0 AS flag FROM vehicle.crossing AS t1 LEFT JOIN ( SELECT * FROM caminfo.devs_ip_status WHERE type
= 95 ) AS t2 ON( t1.crsId = t2.DeviceID ) WHERE t1.type < ; 0 UNION ( SELECT ip AS crsIpint,"" AS crsIpout,name AS crsName,"主伺服器" AS wfdz,1 AS CheckStatus,1 AS flag FROM trk.devs_other WHERE type
= 101 ) LIMIT 0, 20
這個資料請問各位大神程式碼連貫操作該怎麼寫? ? ?
而且用原生SQL 總是報query方法不存在
$Model = M(); 實例化時加個斜杠就好了 query就可以用了
query方法不存在,那就說明$crossingModel不是model,印$crossingModel試試看
方法一
使用query
$sql='';//原生的sql 語句
$res = M()->query($sql);
方法二:
1 $count=M('')-join ()->where($where)->count();//取得總記錄數
//$page 頁碼10每頁顯示資料
2 $pagearr=getPageArr($page,10,$count);
/ /分頁使用的方法建議放在common 中
function getPageArr($page, $pagesize = 10, $count)
{
}
3 然後你的limit可以這樣寫了
->limit($pagearr['start'],$pagearr['pagesize'])