$sSql = "SELECT * FROM table1 where field1 > 0 and field2 IN (:buzzGroups) and active = 1";
$arrParams = array('buzzGroups' => $vBuzzGroups);
$stmt = $this->tableGateway->getAdapter()->createStatement($sSql);
$stmt->prepare($sSql);
$data = $stmt->execute($arrParams);
这里是$vBuzzGroups = '10,12';
当我只传递单个值时,它可以工作但当我尝试传递多个值。逗号分隔的值时,它会给出错误,
Conversion failed when converting the nvarchar value '10,12' to data type int
有人遇到过这个问题吗?
使用implode()函数拆分值
尝试更新后的代码
$arrParams = array('buzzGroups' => $vBuzzGroups);
$sSql = "SELECT * FROM table1 where field1 > 0 and field2 IN
(".implode(',',$arrParams).") and active = 1";