<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Multiple row operations in MySQL / PHP</title>
	<atom:link href="http://www.techfounder.net/2009/05/14/multiple-row-operations-in-mysql-php/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.techfounder.net/2009/05/14/multiple-row-operations-in-mysql-php/</link>
	<description>Blog about web development and Internet entrepreneurship</description>
	<lastBuildDate>Wed, 03 Mar 2010 01:05:40 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.1</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: bonita</title>
		<link>http://www.techfounder.net/2009/05/14/multiple-row-operations-in-mysql-php/comment-page-1/#comment-831</link>
		<dc:creator>bonita</dc:creator>
		<pubDate>Tue, 20 Oct 2009 02:15:29 +0000</pubDate>
		<guid isPermaLink="false">http://www.techfounder.net/?p=229#comment-831</guid>
		<description>hi! what is the best way of inserting multiple entries into one table?

For example: 10 employees to be inserted in one click with their name, email, address.. etc...

Please help..thanks.</description>
		<content:encoded><![CDATA[<p>hi! what is the best way of inserting multiple entries into one table?</p>
<p>For example: 10 employees to be inserted in one click with their name, email, address.. etc&#8230;</p>
<p>Please help..thanks.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Shantanu Oak</title>
		<link>http://www.techfounder.net/2009/05/14/multiple-row-operations-in-mysql-php/comment-page-1/#comment-771</link>
		<dc:creator>Shantanu Oak</dc:creator>
		<pubDate>Wed, 15 Jul 2009 15:48:27 +0000</pubDate>
		<guid isPermaLink="false">http://www.techfounder.net/?p=229#comment-771</guid>
		<description>Thanks for the tip.
I have one question.
 
&gt;&gt; At 2560 rows inserted, it took the loop
What if I need to send tens of thousands of records?
Will the server have any issues?</description>
		<content:encoded><![CDATA[<p>Thanks for the tip.<br />
I have one question.</p>
<p>&gt;&gt; At 2560 rows inserted, it took the loop<br />
What if I need to send tens of thousands of records?<br />
Will the server have any issues?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: thomas</title>
		<link>http://www.techfounder.net/2009/05/14/multiple-row-operations-in-mysql-php/comment-page-1/#comment-769</link>
		<dc:creator>thomas</dc:creator>
		<pubDate>Sat, 06 Jun 2009 19:57:56 +0000</pubDate>
		<guid isPermaLink="false">http://www.techfounder.net/?p=229#comment-769</guid>
		<description>hi i have 3 tables  like a ,b c 
where a  contains employee detail , b contains details of item consumed by each employee and c contains different types of items, one user can have many items

so table b will have more than  one entries of same id


i want to show  in a pattern  like below in webpage

employee 1--  item1 --- item2 --- item 3 --item4
employee 2--  item1 --- &#039;  &#039;--- item 3 --item4
employee --  item1 --- item2 --- item 3 --item4-- item5

i want to fetch the  details in above pattern


i get result in query as belowe

employee1 - item1
employee1-item2
--

---

how could i fetch the details in the patern i want</description>
		<content:encoded><![CDATA[<p>hi i have 3 tables  like a ,b c<br />
where a  contains employee detail , b contains details of item consumed by each employee and c contains different types of items, one user can have many items</p>
<p>so table b will have more than  one entries of same id</p>
<p>i want to show  in a pattern  like below in webpage</p>
<p>employee 1&#8211;  item1 &#8212; item2 &#8212; item 3 &#8211;item4<br />
employee 2&#8211;  item1 &#8212; &#8216;  &#8216;&#8212; item 3 &#8211;item4<br />
employee &#8212;  item1 &#8212; item2 &#8212; item 3 &#8211;item4&#8211; item5</p>
<p>i want to fetch the  details in above pattern</p>
<p>i get result in query as belowe</p>
<p>employee1 &#8211; item1<br />
employee1-item2<br />
&#8211;</p>
<p>&#8212;</p>
<p>how could i fetch the details in the patern i want</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Eran Galperin</title>
		<link>http://www.techfounder.net/2009/05/14/multiple-row-operations-in-mysql-php/comment-page-1/#comment-758</link>
		<dc:creator>Eran Galperin</dc:creator>
		<pubDate>Sat, 16 May 2009 14:45:38 +0000</pubDate>
		<guid isPermaLink="false">http://www.techfounder.net/?p=229#comment-758</guid>
		<description>Plain SQL :) of course, I make sure to properly filter and escape user input</description>
		<content:encoded><![CDATA[<p>Plain SQL <img src='http://www.techfounder.net/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  of course, I make sure to properly filter and escape user input</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Arik Fraimovich</title>
		<link>http://www.techfounder.net/2009/05/14/multiple-row-operations-in-mysql-php/comment-page-1/#comment-757</link>
		<dc:creator>Arik Fraimovich</dc:creator>
		<pubDate>Sat, 16 May 2009 11:07:41 +0000</pubDate>
		<guid isPermaLink="false">http://www.techfounder.net/?p=229#comment-757</guid>
		<description>@Eran &amp; @George - thank you for the information. Going to rewrite some queries now :)

@Eran - &quot;ON DUPLICATE...&quot; in Zend Framework: so you just passing SQL in such cases or made your own wrapper?</description>
		<content:encoded><![CDATA[<p>@Eran &amp; @George &#8211; thank you for the information. Going to rewrite some queries now <img src='http://www.techfounder.net/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>@Eran &#8211; &#8220;ON DUPLICATE&#8230;&#8221; in Zend Framework: so you just passing SQL in such cases or made your own wrapper?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: George</title>
		<link>http://www.techfounder.net/2009/05/14/multiple-row-operations-in-mysql-php/comment-page-1/#comment-756</link>
		<dc:creator>George</dc:creator>
		<pubDate>Fri, 15 May 2009 07:26:46 +0000</pubDate>
		<guid isPermaLink="false">http://www.techfounder.net/?p=229#comment-756</guid>
		<description>@Arik Fraimovich: REPLACE and ON DUPLICATE KEY UPDATE are actually quite different. REPLACE actually deletes the row if it is inserted and then re-inserts it. This means that REPLACE will change any AUTOINCREMENT fields you have in your row, thus wasting IDs and even braking table relationships.</description>
		<content:encoded><![CDATA[<p>@Arik Fraimovich: REPLACE and ON DUPLICATE KEY UPDATE are actually quite different. REPLACE actually deletes the row if it is inserted and then re-inserts it. This means that REPLACE will change any AUTOINCREMENT fields you have in your row, thus wasting IDs and even braking table relationships.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Eran Galperin</title>
		<link>http://www.techfounder.net/2009/05/14/multiple-row-operations-in-mysql-php/comment-page-1/#comment-755</link>
		<dc:creator>Eran Galperin</dc:creator>
		<pubDate>Thu, 14 May 2009 22:26:14 +0000</pubDate>
		<guid isPermaLink="false">http://www.techfounder.net/?p=229#comment-755</guid>
		<description>Yes, definitely the server architecture should be taken into consideration. In this case I would think that sending one query would have even more performance benefits, as remote connections are more costly due to higher latency.

You can always mix-and-match approaches, for example splitting the operations into 6 major query instead of one giant to preserve memory if needed. The performance boost over 2500~ queries would still be significant.</description>
		<content:encoded><![CDATA[<p>Yes, definitely the server architecture should be taken into consideration. In this case I would think that sending one query would have even more performance benefits, as remote connections are more costly due to higher latency.</p>
<p>You can always mix-and-match approaches, for example splitting the operations into 6 major query instead of one giant to preserve memory if needed. The performance boost over 2500~ queries would still be significant.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Andre</title>
		<link>http://www.techfounder.net/2009/05/14/multiple-row-operations-in-mysql-php/comment-page-1/#comment-754</link>
		<dc:creator>Andre</dc:creator>
		<pubDate>Thu, 14 May 2009 22:13:07 +0000</pubDate>
		<guid isPermaLink="false">http://www.techfounder.net/?p=229#comment-754</guid>
		<description>here&#039;s a question.  In a scenario where you have a seperate database server removed from the web application, would it be better to go for the use more memory approach and pass one large SQL statement?  

I think it depends on the server architecture to determine when to use the multiple sql versus one sql solution.</description>
		<content:encoded><![CDATA[<p>here&#8217;s a question.  In a scenario where you have a seperate database server removed from the web application, would it be better to go for the use more memory approach and pass one large SQL statement?  </p>
<p>I think it depends on the server architecture to determine when to use the multiple sql versus one sql solution.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Zippy</title>
		<link>http://www.techfounder.net/2009/05/14/multiple-row-operations-in-mysql-php/comment-page-1/#comment-753</link>
		<dc:creator>Zippy</dc:creator>
		<pubDate>Thu, 14 May 2009 20:49:22 +0000</pubDate>
		<guid isPermaLink="false">http://www.techfounder.net/?p=229#comment-753</guid>
		<description>I&#039;m still relative new to maximizing my db queries, so I really enjoyed this article. Thanks for the response. I can think of a few instances where switching to the methods suggested would benefit.</description>
		<content:encoded><![CDATA[<p>I&#8217;m still relative new to maximizing my db queries, so I really enjoyed this article. Thanks for the response. I can think of a few instances where switching to the methods suggested would benefit.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Eran Galperin</title>
		<link>http://www.techfounder.net/2009/05/14/multiple-row-operations-in-mysql-php/comment-page-1/#comment-752</link>
		<dc:creator>Eran Galperin</dc:creator>
		<pubDate>Thu, 14 May 2009 20:21:03 +0000</pubDate>
		<guid isPermaLink="false">http://www.techfounder.net/?p=229#comment-752</guid>
		<description>@arik:
1. REPLACE is different - if the row exists already it deletes it before insertion. This is not useful for maintaining relationships between tables, and it can cause faster index fragmentation (as rows are constantly deleted and inserted).
2. Unfortunately no... for INSERT and UPDATE it uses just the basic syntax.

@andre:
I benchmarked it using PHP, pasted the results into an excel sheet and made a graph of it :) just tinkered a little with the colors. Too bad excel doesn&#039;t have anti-aliasing...

@zippy:
The problem with using prepared statements for those scenarios is that the size of the query itself is dynamic. If your statement is prepared for one row at a time, it will still execute many times instead of one. 
The overhead might be slightly smaller (as the statement is prepared and cached after one run), but it will still under perform badly against a single query.</description>
		<content:encoded><![CDATA[<p>@arik:<br />
1. REPLACE is different &#8211; if the row exists already it deletes it before insertion. This is not useful for maintaining relationships between tables, and it can cause faster index fragmentation (as rows are constantly deleted and inserted).<br />
2. Unfortunately no&#8230; for INSERT and UPDATE it uses just the basic syntax.</p>
<p>@andre:<br />
I benchmarked it using PHP, pasted the results into an excel sheet and made a graph of it <img src='http://www.techfounder.net/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  just tinkered a little with the colors. Too bad excel doesn&#8217;t have anti-aliasing&#8230;</p>
<p>@zippy:<br />
The problem with using prepared statements for those scenarios is that the size of the query itself is dynamic. If your statement is prepared for one row at a time, it will still execute many times instead of one.<br />
The overhead might be slightly smaller (as the statement is prepared and cached after one run), but it will still under perform badly against a single query.</p>
]]></content:encoded>
	</item>
</channel>
</rss>
