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:bally.zijn@gmail.com]
Sent: April-28-09 3:13 PM
To: cake-php@googlegroups.com
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
<dave@widepixels.com> 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 cake-php@googlegroups.com
To unsubscribe from this group, send email to cake-php+unsubscribe@googlegroups.com
For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---
No comments:
Post a Comment