You are here: Re: insert multi rows with a single mysql function call? « PHP Programming Language « IT news, forums, messages
Re: insert multi rows with a single mysql function call?

Posted by Michael Fesser on 07/21/07 16:19

..oO(Gordon Burditt)

>INSERT INTO `table` (`foo`, `bar`) VALUES
>('$string_1', '$string_2'),
>('$string_3', '$string_4'),
>('$string_5', '$string_6'),
>('$string_7', '$string_8');
>
>Warning: you are limited in the length of the query you can have by
>some mysql parameters, so depending on the length of the strings, you
>may need to limit this to a few thousand records at a time.

Yep, I've run into this before ...

A better solution (IMHO) would be to use PDO and a prepared statement.
The most time-consuming part is to analyze and optimize the query. With
a prepared statement this just has to be done once. After that you just
execute the statement in a loop with all the values you want to insert.

Micha

 

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

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