Tuesday, April 28, 2009

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: