所以我試圖在web2py中使用smart_query來查找數據庫中的特定值,但唯一可以解釋的是在web2py書中,它不是很清楚。從書中的例子GET請求的格式如下:如何使用web2py smart_query獲取GET請求?
def GET(search):
try:
rows = db.smart_query([db.person, db.pet], search).select()
return dict(result=rows)
except:
...
我很困惑,什麼樣的價值觀我會到位db.person和db.pet的。下面是書上這樣說的:
The method db.smart_query takes two arguments:
a list of field or table that should be allowed in the query
a string containing the query expressed in natural language
我想到的第一個值將是我在數據庫中搜索,但我不知道第二個值將是什麼。這本書聽起來應該是我正在搜索的字符串,但我認爲這就是變量搜索的目的。
有人能幫我理解每個參數應該做什麼嗎?