2012-10-12 29 views
0

提取使用正則表達式的數據我想從使用常規expression.This數據庫表中的數據是我做過什麼:在playframework

def getDataRegExp(term: String): Seq[User] ={ 
    DB.withConnection(
     implicit connection => 
     SQL("select * from user where pseudo ~ '^{term}'").on(
     'term -> term 
     ).as(User.simple *) 
    ) 
    } 

但我得到什麼結果中。 我做錯了什麼?

PS:我使用PostgreSQL 9.1

+0

建議:確保按照您期望的方式替換「期限」。之後,它只是一個postgresql問題。 – pedrofurla

+0

@pedrofurla這就是我想要做的。 「術語」並沒有以我想要的方式取代。 –

回答

0

嗯,我succeded在得到結果。它給我所有包含插入的term的用戶。我剛剛刪除了圍繞{term}'^。這是代碼。

def getDataRegExp(term: String): Seq[User] ={ 
    DB.withConnection(
     implicit connection => 
     SQL("select * from user where pseudo ~ {term}").on(
     'term -> term 
     ).as(User.simple *) 
    ) 
    } 
+0

但我仍然不知道如何才能得到以「term」開頭的結果 –