在redbean中查找是否支持多个搜索字段


Does r::find in redbean support more than one search field

我试图通过多个条件进行搜索。我已经在Redbean的网站上搜索了正确的语法,但他们提供的只是使用一个搜索条件的例子。

$match = R::find('tuba', ' displayType = ? ', [ '$displayType' ]);

我还试图通过inventoryNUM进行搜索。我试过执行这个代码,但没有成功。

$match = R::find('tuba', ' displayType = ? , inventoryNUM = ? ', [ '$displayType' , '$inventoryNUM' ]);

这是正确的语法吗?R::find是否支持多个搜索条件?

您可以通过以下方式实现: $match = R::find( 'tuba', ' displayType = ? AND inventoryNUM = ? ', [$displayType, $inventory]);

请记住,第二个参数中的所有内容都是SQL query to find the desired bean, starting right after WHERE clause。也可以使用问号表示法或槽表示法(:keyname)。

以下查询等效于上面的查询: $match = R::find( 'tuba', ' displayType = :displayType AND inventoryNUM = :inventoryNUM ', [':displayType' => $displayType, '':inventoryNUM' => $inventory]);