作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我在mysql查询中使用了以下代码:
$all_PIDs=array();
foreach($pID as $p)
{
$all_PIDs[]=$p->ID;
}
$AIDS=implode(',',$all_PIDs);
$table_tsk = new Timesheets_Table_Tasks();
$select_tsk = $table_tsk->select()
->from($table_tsk, array
(
'Total'=>'SUM(timesheets_tasks.Time)',
'Charged'=>'SUM(timesheets_tasks.Time_Charged)'
))
->where('timesheets_tasks.ProjectID IN ('.$AIDS.')')
;
但是使用上面的代码我收到以下错误:
"An error has occured SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '))' at line 1"
我为 IN
子句添加了引号("
)。但问题是查询仅显示第一个 $AIDS
有人可以帮我清除错误吗?谢谢!
最佳答案
应指定为:
->where('timesheets_tasks.ProjectID IN (?)', $all_PIDs)
因此您传递的是整数数组,而不是逗号分隔的列表
关于php - MYSQL IN 子句错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18434822/
我是一名优秀的程序员,十分优秀!