伟大的程序员从套页面……卧槽。
1.问题描述
- 传入参数的URL:
http://127.0.0.1/index.php/result/receiveresult/7A01A18D-F9DC-3A69-CBAA-784A8FA3DB1C/1440752579/111/22/0.98
其中 7A01A18D-F9DC-3A69-CBAA-784A8FA3DB1C 是作为一个sql查询语句中的where赋值语句传入。
$taskresult = M('taskresult');
$result_data = $taskresult->where('task_code='.$task_code)->setField($data);
- 此时报错:
SQLSTATE[42S22]: Column not found: 1054 Unknown column '7A01A18D' in 'where clause'
也就是说,sql语句中将短横线-作为了分割点。
2.解决办法
解决办法也非常简单,现将查询条件转化为一个数组即可:
$taskresult = M('taskresult');
$result_data = $taskresult->where(array('task_code' => $task_code))->setField($data);
3.短横线-在sql语句中的处理
待续