I actually added the percent to the db, but even though it works its not the best solution as this is a search function so a user searches and the results each get a percent inserted into the db....but that seems like a lot of overhead for the db...constantly updating the percent field every time a search is run and results found for each post.
My code is just this from a tutorial http://foldifoldi.com/news/?p=271 Except: $jobs = array(); foreach ($this->Job->find('all', $params) as $row) { array_push($jobs, $row['Job']['id']); $job_id = $row['Job']['id']; $program_matches = count(array_intersect($this->data['Program']['Program'], Set::extract($q, 'Program.{n}.id'))); $language_matches = count(array_intersect($this->data['Language']['Language'], Set::extract($q, 'Language.{n}.id'))); $matches = $program_matches + $language_matches; $searchCount = $searchProgramCount + $searchLanguageCount; $percent = ceil(($matches / $searchCount) * 100); $this->Job->id = $q['Job']['id']; //debug($q['Job']['id']); $this->Job->saveField('percent', $percent); } I would like to explore the idea of afterFind but that's new to me as I have never used it yet. Hw would I go about that? -----Original Message----- From: kdubya [mailto:kenwin...@winanstech.com] Sent: June-22-09 11:45 PM To: CakePHP Subject: Re: Makes no sense Dave, Keep in mind that Paginate is like doing a $this->Model->find(). The options setup in the $paginate variable in the controller are setting up the arguments to a find-like SQL query on your database. Every time a new page is requested (by the user clicking on the next page link) causes a new query to be run on the database. So any post-processing you did on the results of the query once will need to be done again. You might try setting up a afterFind() function in your Model but you haven't posted enough actual code here for me to tell if this might work. You might consider storing the percent field in the Model (database). Then Paginate will work. Ken --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---