1
我想確保格式化查詢中的子句。例如,我有以下代碼:用於like查詢的whereWithFormat的DBAccess格式結構
int count = [[[MyDBObject query] whereWithFormat:@"url like '%%@%'", mySearchString] count];
我的問題是:我使用的是像第正確的格式?
謝謝你,快樂編碼:)
我想確保格式化查詢中的子句。例如,我有以下代碼:用於like查詢的whereWithFormat的DBAccess格式結構
int count = [[[MyDBObject query] whereWithFormat:@"url like '%%@%'", mySearchString] count];
我的問題是:我使用的是像第正確的格式?
謝謝你,快樂編碼:)
由於字符串格式不喜歡這一點,我們必須適應,並作出特殊參數類型,因此我們可以將其識別爲一個像參數。因爲字符串格式化是一個部分,但隨後參數被提供給查詢,格式化變得非常麻煩,並且您必須對轉義字符進行相當有創意。
所以,你需要的東西是dbMakeLike()
例子:
whereWithFormat:@"lower(text) LIKE %@「, dbMakeLike(searchString.lowercaseString)
感謝
謝謝你,爲我工作。 – Horatiu