Just create a validation rule pointing to a method in the System model. Fetch the values from the table and compare to whatever was submitted.
On Tue, Apr 28, 2009 at 2:48 PM, Dave Maharaj :: WidePixels.com <[email protected]> wrote: > > Ok I see now array_unique($this->data[$model_name][$model_name] removes > duplicate values. > > My question now expands as I keep testing edited values with FireBug > > Example my checkbox values range from 1 - 15. I can edit the value to 999 > which there is nothing for and check the table and sure enough 999 is saved > there. How can I get the values that do exists and compare them against the > submitted values? > > I am doing this in AJAX so I believe the Security component will be of no > assistance to me. > > Ideas? > > Thanks, > > Dave > > -----Original Message----- > From: Dave Maharaj :: WidePixels.com [mailto:[email protected]] > Sent: April-28-09 3:29 PM > To: [email protected] > Subject: RE: Check array for duplicate > > > Ok right on....seems to get me started. > > I have this in my controller but if there is a duplicate its not saving > which is what I want) but skipping past the }else{ > > Ideas what i am missing? > > if (!empty($this->data)) { > $san = new Sanitize(); > $this->data = $san->clean($this->data); > if ($this->data[$model_name][$model_name] = > array_unique($this->data[$model_name][$model_name])) { > $this->User->save($this->data); > $this->skills($model); > } else { > $value = 'Messing around with values'; > $this->User->id = $this->Auth->user('id'); > //set confirm code to zero disableing login > //$this->User->saveField('confirmed', 0); > $this->set('value', $value); > $this->layout = 'ajax'; > $this->render('/errors/hack_attempt'); > } > } > -----Original Message----- > From: brian [mailto:[email protected]] > Sent: April-28-09 3:13 PM > To: [email protected] > Subject: Re: Check array for duplicate > > > $this->data['System']['System'] = > array_unique($this->data['System']['System']); > > On Tue, Apr 28, 2009 at 1:33 PM, Dave Maharaj :: WidePixels.com > <[email protected]> wrote: >> >> I have modified my form value using Firebug and I get this array >> (which should never happen unless someone has edited the form and >> tried submitting the altered values) >> >> How could I create a quick 'check the values' function for duplicates >> to see if someone was trying to mess with the site? >> >> >> Array >> ( >> [System] => Array >> ( >> [System] => Array >> ( >> [0] => 1 >> [1] => 1 >> [2] => 1 >> ) >> >> ) >> >> ) >> >> I have the db set so the fields have to be unique so it will not >> save...but the view shows SQL Error: 1062: Duplicate entry '1-3' for >> key 2 >> Query: INSERT INTO `users_systems` (`user_id`,`system_id`) VALUES >> (3,'1'), (3,'1'), (3,'1') >> >> I would like to check the array for duplicte values before saving, if >> found then destroy user session, display message and ban user...just >> cant figure ot how to check the array for duplcates. >> >> Ideas? >> >> thanks >> >> >> Dave >> >> >> > >> > > > > > > > > --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
