我试图通过使用“IN”以及“=”来找到一些bean。我目前使用此代码:使用IN与Redbean中的其他条件
$ids = array(1,2,3,4);
$user = 1;
$things = R::find(
'thing',
'id IN ('.R::genSlots($ids).') AND user = ?',
array(
$ids,
$user
)
);
这给了我一些错误:
PHP Notice: Array to string conversion in rb.php on line 217
Fatal error: Uncaught [HY093] - SQLSTATE[HY093]: Invalid parameter number: number of bound variables does not match number of tokens thrown in rb.php on line 267
如果我在的$ id一个项目运行这段代码我只得到了通知,但无论哪种方式,我没有得到任何结果。
我假设它试图把$ id当作一个单独的变量。我错过了什么?
你确定'R :: genSlots()'接受一个数组吗? – TheWolf
这不是它的用途吗? –
为什么不简单地使用implode(',',$ ids)而不是R :: genSlots? – OIS