2015-02-24 44 views
0

我正在嘗試通過多個條件進行搜索。我已經在Redbean的網站上搜索了正確的語法,但他們提供的僅僅是僅使用一個搜索條件的示例。r ::在redbean中查找是否支持多個搜索字段

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

我想通過inventoryNUM進行搜索。我試圖執行此代碼,但無濟於事。

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

這是正確的語法嗎? R ::查找是否支持多個搜索條件?

回答

0

你可以做到這一點有以下幾點: $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]);