2012-11-14 102 views
0

我正在嘗試做一個數據網格的遠程過濾。如何在Propel中使用Mysql concat?

網格有一個文本框,用戶輸入字符,發送到服務器刷新網格。

我的問題是,我正在使用Propel來處理數據庫,我需要concat兩個MySQL字段來做比較。我不知道在Propel中如何做一個簡單的where concat(firstname, ',', lastname) like '%aText%'

我已經試過:

$usuarios = UsuariosQuery::create() 
    ->where("(concat(usuarios.apellido,' , ',usuarios.nombre)) LIKE '%?%'",$filter) 
    ->orderByApellido('ASC') 
    ->find(); 

這是行不通的。我怎樣才能使這個工作?

回答

0

試試這個according to the doc(搜索concat):

$usuarios = UsuariosQuery::create() 
    ->where('CONCAT(Usuarios.Apellido, ",", Usuarios.Nombre) LIKE ?', $filter) 
    ->orderByApellido('ASC') 
    ->find(); 
}}} 
+0

謝謝!我測試你的建議,並努力工作!但我寫了where子句: where('CONCAT(Usuarios.Apellido,「,」,Usuarios.Nombre)LIKE?',「%$ filter%」)。 – ramiromd