2012-11-14 191 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