时间:2021-07-01 10:21:17 帮助过:22人阅读
这样生成的sql为
1 SELECT 2 `dz_region`.`text` AS `sitone`, 3 `dz_station`.`North`, 4 `dz_station`.`East`, 5 `dz_station`.`state`, 6 `dz_station`.`stabianhao`, 7 `dz_station`.`staname`, 8 `dz_station`.`siteonename`, 9 `dz_station`.`sitetwoname`, 10 `dz_station`.`sitename`, 11 `dz_station`.`statype`, 12 `dz_station`.`settime`, 13 `dz_station`.`staid` 14 FROM 15 `dz_station` 16 LEFT JOIN `dz_region` ON `dz_region`.`linkageid` = `dz_station`.`sitetwoname` 17 WHERE 18 `isdel` = 0 19 AND ( 20 `dz_station`.`sitetwoname` IN ( 21 ‘1‘, 22 ‘199‘, 23 ‘203‘, 24 ‘197‘, 25 ‘209‘, 26 ‘208‘ 27 ) 28 OR `dz_station`.`siteonename` IN ( 29 ‘1‘, 30 ‘199‘, 31 ‘203‘, 32 ‘205‘, 33 ‘211‘, 34 ‘197‘, 35 ‘209‘, 36 ‘208‘ 37 ) 38 OR 1 = 2 39 ) 40 AND 1 IN (‘1‘)
以上
如果不采用我的办法生成的sql为
SELECT `dz_region`.`text` AS `sitone`, `dz_station`.`North`, `dz_station`.`East`, `dz_station`.`state`, `dz_station`.`stabianhao`, `dz_station`.`staname`, `dz_station`.`siteonename`, `dz_station`.`sitetwoname`, `dz_station`.`sitename`, `dz_station`.`statype`, `dz_station`.`settime`, `dz_station`.`staid` FROM `dz_station` LEFT JOIN `dz_region` ON `dz_region`.`linkageid` = `dz_station`.`sitetwoname` WHERE `isdel` = 0 AND `dz_station`.`sitetwoname` IN ( ‘1‘, ‘199‘, ‘203‘, ‘205‘, ‘197‘, ‘209‘, ‘208‘ ) OR `dz_station`.`siteonename` IN ( ‘1‘, ‘199‘, ‘203‘, ‘205‘, ‘211‘, ‘209‘, ‘208‘ )
当然这是不满足需求的,至于为什么不用原生sql,因为数组不好处理,
ci框架 用框架自带db 添加括号,比如 like 等等左右添加括号 解决办法
标签:pos site color 生成 die 查询 text 左右 list