With a little poking around I think I have found the true issue here. When you click on a paginate link, it appends 'page:2' or whatever page it is going to to your url and then internally uses the previously saved query to get the next set of records. But 'page:2' is not passed in as an argument or at least I am not able to capture it to test if a paginate query is being performed or if this is the first time I am loading the page and nothing has been asked for yet. So my question is this. How do I know if a paginate query is being performed as opposed to the page loading for the first time.
~Michael On Thu, Sep 2, 2010 at 5:37 PM, Michael Gaiser <mjgai...@gmail.com> wrote: > 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 <zijn.digi...@gmail.com> 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 <mjgai...@gmail.com> >> 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 cake-php@googlegroups.com >> > To unsubscribe from this group, send email to >> > cake-php+unsubscr...@googlegroups.com<cake-php%2bunsubscr...@googlegroups.com>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 cake-php@googlegroups.com >> To unsubscribe from this group, send email to >> cake-php+unsubscr...@googlegroups.com<cake-php%2bunsubscr...@googlegroups.com>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 cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en