cari

Rumah  >  Soal Jawab  >  teks badan

mysql - Masalah dengan operasi koheren dalam ThinkPHP3.2.3?

Kod


Pernyataan SQL ialah
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 )

Apa yang saya mahukan ialah
PILIH 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 ) HAD 0,20
Data ini bolehkah anda beritahu saya cara menulis kod yang koheren? ? ?

Dan apabila menggunakan SQL asli, ia sentiasa melaporkan bahawa kaedah pertanyaan tidak wujud

过去多啦不再A梦过去多啦不再A梦2688 hari yang lalu929

membalas semua(3)saya akan balas

  • ringa_lee

    ringa_lee2017-07-05 10:48:05

    $Model = M(); Hanya tambah garis miring apabila membuat instantiat dan pertanyaan boleh digunakan

    balas
    0
  • 扔个三星炸死你

    扔个三星炸死你2017-07-05 10:48:05

    kaedah pertanyaan tidak wujud, itu bermakna $crossingModel bukan model, cuba cetak $crossingModel

    balas
    0
  • PHP中文网

    PHP中文网2017-07-05 10:48:05

    Kaedah satu
    Gunakan pertanyaan
    $sql='';//Penyataan sql asli
    $res = M()->query($sql);
    Kaedah dua:
    1 $count=M('')- sertai ()->where($where)->count();//Dapatkan jumlah rekod
    //$halaman nombor halaman 10 memaparkan data pada setiap halaman
    2 $pagearr=getPageArr($page,10, $count) ;
    //Kaedah yang digunakan untuk paging disyorkan untuk diletakkan bersama
    fungsi getPageArr($page, $pagesize = 10, $count)
    {

    $page                    = isset($page) ? abs(intval($page)) : 1;
    $pagesize                = isset($pagesize) ? abs(intval($pagesize)) : 10;
    $page > 100000 && $page  = 100000;
    $pagesize > 100 && $page = 100;
    $pagetotal               = ceil($count / $pagesize);
    ($page > $pagetotal) && ($page = $pagetotal);
    ($page < 1) && ($page = 1);
    
    //下一页
    if ($page > $pagetotal) {
        $nextpage = $pagetotal;
    } else {
        $nextpage = $page + 1;
    }
    //上一页
    if ($page > 1) {
        $prevpage = $page - 1;
    } else {
        $prevpage = $page;
    }
    
    $pagearr = array(
        "page"      => $page,
        "pagesize"  => $pagesize,
        "pagetotal" => $pagetotal,
        "count"     => $count,
        "start"     => ($page - 1) * $pagesize,
        "nextpage"  => $nextpage,
        "prevpage"  => $prevpage,
    
    );
    return $pagearr;

    }
    3 Kemudian had anda boleh ditulis seperti ini

    ->had($pagearr['mula'],$pagearr['pagesize'])

    balas
    0
  • Batalbalas