【问题标题】:how apply Mysql concat in Propel?如何在 Propel 中应用 Mysql concat?
【发布时间】:2012-11-14 16:38:34
【问题描述】:

我正在尝试对数据网格进行远程过滤。

网格有一个文本字段,用户可以在其中输入发送到服务器以刷新网格的字符。

我的问题是我使用 Propel 来处理数据库,我需要连接两个 MySQL 字段来进行比较。我不知道如何在 Propel 中做一个简单的where concat(firstname, ',', lastname) like '%aText%'

我试过了:

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

这不起作用。我怎样才能让它工作?

【问题讨论】:

    标签: mysql orm where propel concat


    【解决方案1】:

    试试这个according to the doc(搜索concat):

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

    【讨论】:

    • 谢谢!!我测试你的建议,然后工作!但是我写了 where 子句: where('CONCAT(Usuarios.Apellido, ",", Usuarios.Nombre) LIKE ?', "%$filter%").
    猜你喜欢
    • 2010-09-20
    • 2012-11-07
    • 1970-01-01
    • 1970-01-01
    • 2019-02-02
    • 2019-04-16
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多