【问题标题】:How to convert SQL query to CakePHP query如何将 SQL 查询转换为 CakePHP 查询
【发布时间】:2014-07-08 05:22:33
【问题描述】:

我有以下查询,其中interest 是字段名称。 interest 包含足球、排球等。

SELECT * FROM `drop_down_multiples` where find_in_set('football',`interest`);

我坚持在CakePHP 中转换上述查询。如何转换?

谢谢。

【问题讨论】:

    标签: cakephp


    【解决方案1】:

    类似这样的事情:-

    cakephp 没有任何功能,你必须做一些技巧,即 cakephp 如何构建 sql 从它们的语法中查询。

    $this->DropDownMultiples->find('all',array(
      'conditions'=>array('FIND_IN_SET("'.$search_field.'",DropDownMultiple.interest)‌​')
      ));
    

    【讨论】:

    • place_here_list 是什么意思?
    • 你必须改变这样的东西'conditions'=>array('FIND_IN_SET("'.$search_field.'",DropDownMultiple.interest)')
    • @Sadikhasan 其中必须搜索interest 字段
    • 您最接近解决方案,但您必须更改上面提到的find_in_set 的语法
    • 你的意思是 DropDownMultiple.interest 有逗号分隔的值吗?你应该在问题中提到。
    猜你喜欢
    • 2010-12-22
    • 1970-01-01
    • 1970-01-01
    • 2022-06-14
    • 2020-07-19
    • 2021-10-11
    • 2017-10-29
    • 2015-04-21
    • 2019-04-24
    相关资源
    最近更新 更多