报错:1054:Unknown column 'city' in 'where clause' [ SQL语句 ] : SELECT * FROM `iot_paths'WHERE....
错误提示:
1054:Unknown column 'xxx' in 'where clause' [ SQL语句 ] : SELECT * FROM `iot_paths` WHERE ( city= xx )
thinkPHP3.2 报错1054,百度搜索了下,发现是变量的数据类型错误导致的该问题,代码如下:
$cityInfos = $_SESSION['path'];
$pathinfo=$pathCity->where("city= {$cityInfos} ")->field('citys,appkeys,secrets,group')->find();
$pathinfo是字符串类型,需要在变量添加单引号,解决如下:
$cityInfos = $_SESSION['path'];
$pathinfo=$pathCity->where("city= '{$cityInfos}' ")->field('citys,appkeys,secrets,group')->find();