Re: Re: [PHP] How can I find database records that were NOT just updated
| From: | Chris Carbaugh | Date: | Mon, 20 Nov 2000 02:58:08 +0000 |
| Subject: | Re: Re: [PHP] How can I find database records that were NOT just updated | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-26096@lists.php.net to get a copy of this message | ||
Looks like it will do what I need.
Ain't PHP great :)
Thanks,
Chris
On Sat, 18 Nov 2000, Reuben D Budiardja wrote:
> Date: Sat, 18 Nov 2000 21:34:12 -0500
> To: cjtech2000@yahoo.com,
> "php-general@lists.php.net" <php-general@lists.php.net>
> From: "Reuben D Budiardja" <reubendb@goshen.edu>
> Subject: Re: [PHP] How can I find database records that were NOT just
> updated
>
> There is a built in function array_diff for php4 that should do what
> you
> want, that might be more efficient:
>
> $array_were_not_updated = array_diff($array1, $array2);
>
> http://www.php.net/manual/function.array-diff.php
>
> Reuben D. Budiardja
>
> At 09:01 PM 11/19/00 -0500, Chris Carbaugh wrote:
>
> >OK, let me first explain what I'm trying to do:
> >
> >I have a table with about 100 records. Each record has a unique ID.
> >A script then adds records to this table, or updates the record if
> it
> >already exists (based on the ID).
> >
> >I then need to get a list of all the records that were NOT just
> >inserted or updated.
> >
> >The only way I can think of to do this is as follows:
> >
> >I define two single dimension arrays:
> > the first one ($array1) contains the ID's of every record
> in the
> > table
> >before it is updated
> > the second one ($array2) conatins the ID's of every record
> that was
> >inserted or updated
> >
> >I then do something like:
> > $i = 0;
> > while ($array1[$i]){
> > $j = 0;
> > while ($array2[$j]){
> > if ($array1[$i] == $array2[$j]){
> > < delete $array1[$i] from $array1 >
> > }
> > $j++;
> > }
> > $i++;
> > }
> >
> >This way though, I have to traverse array2 once for every element
> in
> >array1. With both arrays being ~100 elements (and they will grow),
> >this will take some time.
> >
> >Anybody have a more efficient way of doing this?
> >
> >Thanks,
> >
> >Chris
> >--
> >"Without the threat of death, there's no reason to live at all" -
> >Marilyn Manson
> >
> >
> >--
> >PHP General Mailing List (http://www.php.net/)
> >To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net
> >For additional commands, e-mail: php-general-help@lists.php.net
> >To contact the list administrators, e-mail:
> php-list-admin@lists.php.net
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net
> For additional commands, e-mail: php-general-help@lists.php.net
> To contact the list administrators, e-mail:
> php-list-admin@lists.php.net
>
--
"I love my country. I fear my government." - Bumper Sticker