gpt4 book ai didi

php - 在 Redbean 中将 IN 与其他条件一起使用

转载 作者:行者123 更新时间:2023-12-03 23:02:56 27 4
gpt4 key购买 nike

我正在尝试使用“IN”和“=”来查找一些 bean。我目前正在使用此代码:

$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 视为单个变量。我错过了什么?

最佳答案

不要将 $ids 添加到数组中,将两者合并为一个数组,否则这将成为一个嵌套数组。

关于php - 在 Redbean 中将 IN 与其他条件一起使用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19100514/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com