我想在cakedc搜索中使用和/或连接器:当我搜索" PHP +使用SQL,Java"要求不要改变' +'对于','到OR

时间:2015-08-11 17:24:22

标签: cakedc cakephp-2.6

我的模特User.php

public $hasAndBelongsToMany = array(
        'Competence' => array(
            'with' => 'CompetencesUser',
            'className' => 'Competence',
            'joinTable' => 'competences_users',
            'foreignKey' => 'user_id',
            'associationForeignKey' => 'competence_id',
            'unique' => 'keepExisting',

my $ filterArgs()在我的模型User.php中我以前用来修改$ query中的请求

'competences' => array(
            'type' => 'subquery',
            'method' => 'findByCompetences',
            'field' => 'User.id',
            'before'=>true)

我的函数findByCompetences($ data = array())我想要cometence1和compe2以及能力3或能力4

 $this->CompetencesUser->Behaviors->attach('Containable', array(
                'autoFields' => false
            )
        );

        $this->CompetencesUser->Behaviors->attach('Search.Searchable');


        $query = $this->CompetencesUser->getQuery('all', array(
            'conditions' =>
        array(

        'Competence.competence' => $data['competences'],
        'fields' => array(
                'foreign_key'
            ),
            'contain' => array(
                'Competence'
            ),

        'search_with_connectors' => array(
        'type' => 'like',
        'field' => 'Competence.competence',
        'connectorAnd' => '+', 'connectorOr' => ','
    )

        )));
         return $query;
    }

0 个答案:

没有答案