title: Cakephp $this->paginate with custom JOIN and filtering options
body: <p>I've been working with cakephp paginations options for 2 days. I need to make a INNER Joins to list a few fields, but I have to deal with search to filter results.
  This is portion of code in which I deal with search options by <code>$this-&gt;passedArgs</code></p>
  
  <pre><code>function crediti() {
  
      if(isset($this-&gt;passedArgs['Search.cognome'])) {
                  debug($this-&gt;passedArgs);
  
                  $this-&gt;paginate['conditions'][]['Member.cognome LIKE'] = str_replace('*','%',$this-&gt;passedArgs['Search.cognome']);
  
          }
          if(isset($this-&gt;passedArgs['Search.nome'])) {
                  $this-&gt;paginate['conditions'][]['Member.nome LIKE'] = str_replace('*','%',$this-&gt;passedArgs['Search.nome']);
  
          }
  </code></pre>
  
  <p>and after </p>
  
  <pre><code>$this-&gt;paginate = array(
  
              'joins' =&gt; array(array('table'=&gt; 'reservations',
              'type' =&gt; 'INNER',
              'alias' =&gt; 'Reservation',
              'conditions' =&gt; array('Reservation.member_id = Member.id','Member.totcrediti &gt; 0' ))),
              'limit' =&gt; 10);
          $this-&gt;Member-&gt;recursive = -1;
          $this-&gt;paginate['conditions'][]['Reservation.pagamento_verificato'] = 'SI';
          $this-&gt;paginate['fields'] = array('DISTINCT Member.id','Member.nome','Member.cognome','Member.totcrediti');
          $members = $this-&gt;paginate('Member');
          $this-&gt;set(compact('members'));
  </code></pre>
  
  <p>INNER JOIN works good, but $this->paginations ignore every <code>$this-&gt;paginate['conditions'][] by $this-&gt;passedArgs</code> and I cannot have idea how I can work it out.
  No query in debug, just the original <code>INNER JOIN</code>.
  Can someone helps me ?
  Thank you very much </p>
  
  <p>Update: 
  No luck about it. 
  I've been dealing with this part of code for many hours. 
  If I use </p>
  
  <pre><code>if(isset($this-&gt;passedArgs['Search.cognome'])) {
                      $this-&gt;paginate['conditions'][]['Member.cognome LIKE'] = str_replace('*','%',$this-&gt;passedArgs['Search.cognome']);
  
              }
  $this-&gt;paginate['conditions'][]['Member.sospeso'] = 'SI';
          $this-&gt;Member-&gt;recursive = 0;
          $this-&gt;paginate['fields'] = array(
              'Member.id','Member.nome','Member.cognome','Member.codice_fiscale','Member.sesso','Member.region_id',
              'Member.district_id','Member.city_id','Member.date','Member.sospeso','Region.name','District.name','City.name');
          $sospesi = $this-&gt;paginate('Member');
  </code></pre>
  
  <p>everything goes well, and from debug I receive the first condition and the conditions from <code>$this-&gt;paginate['conditions'][]['Member.cognome LIKE']</code>, as you can see 
  array <code>$this-&gt;passedArgs</code></p>
  
  <pre><code>Array
  (
      [Search.cognome] =&gt; aiello
  )
  
  Array $this-&gt;paginate['conditions'][]
  (
      [0] =&gt; Array
          (
              [Member.cognome LIKE] =&gt; aiello
          )
  
      [1] =&gt; Array
          (
              [Member.sospeso] =&gt; NO
          )
  </code></pre>
  
  <p>But, if I write the joins with paginate , <code>$this-&gt;paginate['conditions'][]</code> will ignore all the stuff, and give me from debug, just         <code>$this-&gt;paginate['conditions'][]['Reservation.pagamento_verificato'] = 'SI';</code>
  Another bit of information. 
  If I put all the stuff dealing with         <code>$this-&gt;paginate['conditions'][]['Reservation.pagamento_verificato'] = 'SI';</code>
  before the <code>$this-&gt;paginate JOIN</code>, nothing will be in <code>$this-&gt;paginate['conditions'][]</code>.</p>