Code
Die SQL-Anweisung lautet
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 trk.devs_other WHERE type
= 101 )
Was ich möchte ist
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
Diese Daten Können Sie mir bitte sagen, wie man einen kohärenten Code schreibt? ? ?
Und bei der Verwendung von nativem SQL wird immer gemeldet, dass die Abfragemethode nicht existiert
$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'])