You are here: Re: [PHP] SELECT? « PHP « IT news, forums, messages
Re: [PHP] SELECT?

Posted by "Richard Lynch" on 12/30/05 22:29

On Wed, December 28, 2005 2:50 am, William Stokes wrote:
> I have one MySQL table with about 500 rows. I need to read the table
> one row
> at a
> time, make some changes to data in one field and then store the
> changed data
> to another table.
>
> I'm using PHP to change the data but I have no idea how to select one
> row at
> a time from the DB table. There's one auto-increment id field in the
> table
> but the id's doesn't start from 1 and are not sequential.

The suggestions so far are good, but watch out for this:

If you do one record at a time, and are using LIMIT, and then
something gets inserted into the original table...

Boom!

Ordering by the auto_increment will "work" to make sure the new rows
are at the end, but that's kind of icky to rely on in production code.

Your best bet probably is to just get all 500 records and process them
in one batch.

After that, adding a column to mark records "done" or not is good.

Relying solely on LIMIT and auto_increment is only okay for a quick
one-time hack you'll never need again... And still kind of icky.

--
Like Music?
http://l-i-e.com/artists.htm

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация