I was meaning $results didnt have any info in it. When I debug($results), it
is just an empty array. I think this has something to do with the fact that
the paginate link doesnt supply the views form again, so some of the info I
am looking for before doing the query doesnt exist the 2nd time around.

~Michael

On Thu, Sep 2, 2010 at 10:30 AM, cricket <[email protected]> wrote:

> When you say that the query is empty, do you mean $results? Or are you
> referring to the DB query itself (as printed at the bottom of the
> page, for example)?
>
> Have you tried debugging $searchOptions immediately after the switch
> block? Perhaps also debug $this->data at the beginning of the action.
>
> On Thu, Sep 2, 2010 at 11:24 AM, Michael Gaiser <[email protected]>
> wrote:
> > So, I have been trying to get this paginate feature working and I can get
> > the first page properly, but when it returns the 2nd page, the query is
> > empty. Anyone see anything wrong? I suspect it has something to do with
> the
> > $searchStr arg but am unsure how to get around not having an arg in that
> > function. Thanks.
> >
> > ~Michael
> >
> >
> >
> >     function index($searchStr = null) {
> >         $results = array();
> >
> >         //Use the searchStr if there is no data.
> >         if(empty($this->data) && $searchStr != null) {
> >             $this->data['autoComplete'] = $searchStr;
> >             $this->data['Location']['constrainType'] = -1;
> >         }
> >
> >         if (!empty($this->data)) {
> >             $autoCompleteStr = '';
> >             if($this->data['autoComplete'] != '**') {
> >                 $autoCompleteStr = $this->data['autoComplete'];
> >             }
> >
> >             $locationType = $this->data['Location']['constrainType'] - 1;
> >             if ($locationType < 0) $locationType = "%";
> >
> >
> >
> >             $this->paginate = array(
> >                 'limit'=>10,
> >                 'contain' =>array('ParentLocation.name',
> > 'ParentLocation.type', 'ParentLocation.id', 'ConfirmedUser.username'),
> >                 'fields'=>array('Location.id', 'Location.name',
> > 'Location.type', 'Location.parent_id', 'Location.longitude',
> > 'Location.latitude', 'Location.confirmed_id'),
> >                 'order'=>array('Location.name ASC')
> >             );
> >             $searchOptions = array('Location.name LIKE' =>
> > $autoCompleteStr.'%', 'Location.type' => $locationType);
> >
> >
> >             switch($this->data['Location']['adminConstrainType']){
> >                 case 0:
> >                 default:
> >                     break;
> >
> >                 case 1:
> >                     //Non Confirmed
> >                     $adminCondition = array('Location.confirmed_id' =>
> > null);
> >                     $searchOptions = array_merge($searchOptions,
> > $adminCondition);
> >                     break;
> >
> >                 case 2:
> >                     //Confirmed
> >                     $adminCondition = array('Location.confirmed_id <>' =>
> > null);
> >                     $searchOptions = array_merge($searchOptions,
> > $adminCondition);
> >                     break;
> >             }
> >             $results = $this->paginate('Location', $searchOptions);
> >
> >             $this->set('locations', $results);
> >             debug($results);
> >         }
> >         $this->set('constrainTypes', $this->__getConstrainTypes());
> >         $this->set('autocomplete', $this->data['autoComplete']);
> >         $this->set('adminContrainTypes',
> $this->__getAdminContrainTypes());
> >     }
> >
> > Check out the new CakePHP Questions site http://cakeqs.org and help
> others
> > with their CakePHP related questions.
> >
> > You received this message because you are subscribed to the Google Groups
> > "CakePHP" group.
> > To post to this group, send email to [email protected]
> > To unsubscribe from this group, send email to
> > [email protected]<cake-php%[email protected]>For
> >  more options, visit this group at
> > http://groups.google.com/group/cake-php?hl=en
> >
>
> Check out the new CakePHP Questions site http://cakeqs.org and help others
> with their CakePHP related questions.
>
> You received this message because you are subscribed to the Google Groups
> "CakePHP" group.
> To post to this group, send email to [email protected]
> To unsubscribe from this group, send email to
> [email protected]<cake-php%[email protected]>For
>  more options, visit this group at
> http://groups.google.com/group/cake-php?hl=en
>

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected] For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en

Reply via email to