Tuesday, August 18, 2015

CAKEDC Search i want use search with and/or connectors

i want search by competence forexample $data['competences'] =java+oracle,sql then the method of the request competence must know java is first oracle is second and sql is third.

favorite

i want search by competence forexample $data['competences'] =java+oracle,sql then the method of the request competence must know java is first oracle is second and sql is third.

in my query request i have this surprise:

SELECT User.id, User.username, User.nom, User.prenom, User.email, User.password, User.created, User.modified FROM dcsearch.users AS User WHERE User.id in (SELECT CompetencesUser.user_id FROM dcsearch.competences_users AS CompetencesUser LEFT JOIN dcsearch.competences AS Competence ON (CompetencesUser.competence_id = Competence.id) WHERE ((((Competence.competence LIKE '%First\%%') AND (Competence.competence LIKE '%Second\%%'))) OR (Competence.competence LIKE '%Third\%%'))) LIMIT 20

this is my model user.php

im my $filterArgs
'competences' => array(
'type' => 'subquery',
'method' => 'findByCompetences',
'field' => 'User.id',

'connectorsAnd' => '+', 
'connectorOr' => ',',
'before' => true,
'after' => true

);
in my method findByCompetences

public function findByCompetences($data = array()) {

    $this->CompetencesUser->Behaviors->attach('Containable', array(              'autoFields' => false          )      );      $this->CompetencesUser->Behaviors->attach('Search.Searchable');      $data = array('competences' => 'First%+Second%, Third%');        $result = $this->CompetencesUser->parseCriteria($data);        $expected = array(0 => array('OR' => array(          array('AND' => array(              array('Competence.competence LIKE' => '%First\%%'),              array('Competence.competence LIKE' => '%Second\%%'),          )),          array('AND' => array(              array('Competence.competence LIKE' => '%Third\%%')          )),      )));          $query = $this->CompetencesUser->getQuery('all', array(           'conditions' =>array(          $expected,          $result),           'fields' => array(            'user_id'         ),          'contain' => array(             'Competence'  

)));
return $query;
}
i have this Error Invalid argument supplied for foreach()

--
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

---
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscribe@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/d/optout.

No comments: