<?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: Using MySQL Stored Procedures with PHP mysql/mysqli/pdo</title>
	<atom:link href="http://www.joeyrivera.com/2009/using-mysql-stored-procedures-with-php-mysqlmysqlipdo/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.joeyrivera.com/2009/using-mysql-stored-procedures-with-php-mysqlmysqlipdo/</link>
	<description>Blogging about PHP, Actionscript, MySQL, and other interests.</description>
	<lastBuildDate>Thu, 11 Mar 2010 06:56:09 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.1</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: DonM</title>
		<link>http://www.joeyrivera.com/2009/using-mysql-stored-procedures-with-php-mysqlmysqlipdo/comment-page-2/#comment-242</link>
		<dc:creator>DonM</dc:creator>
		<pubDate>Mon, 08 Feb 2010 22:08:32 +0000</pubDate>
		<guid isPermaLink="false">http://www.joeyrivera.com/?p=284#comment-242</guid>
		<description>Thanks for the reply, Joey. Your blog at least got me started looking in the right direction.

I think there was something wrong with my initial code like you said - but the main thing I lacked was an understanding of the meaning of these constants and functions. The error messages didn&#039;t make sense.

The best explanation I came across was in the big bible of &quot;MySQL Developer&#039;s Library&quot; 4th edition by Paul DuBois.  He has a whole section pp 398-400, &quot;7.4.5 mysql_store_result() vs. mysql_use_result()&quot; dedicated to explaining the differences between the two - and how to use them in different examples.

Basically &quot;store&quot; retrieves the whole result set, allocating memory for all rows and buffers them on the client side, whereas &quot;use&quot; doesn&#039;t retrieve any rows at all - you need to use fetch_row to do row by row retrieval.

Anyways - glad I found your blog - keep it up!</description>
		<content:encoded><![CDATA[<p>Thanks for the reply, Joey. Your blog at least got me started looking in the right direction.</p>
<p>I think there was something wrong with my initial code like you said &#8211; but the main thing I lacked was an understanding of the meaning of these constants and functions. The error messages didn&#8217;t make sense.</p>
<p>The best explanation I came across was in the big bible of &#8220;MySQL Developer&#8217;s Library&#8221; 4th edition by Paul DuBois.  He has a whole section pp 398-400, &#8220;7.4.5 mysql_store_result() vs. mysql_use_result()&#8221; dedicated to explaining the differences between the two &#8211; and how to use them in different examples.</p>
<p>Basically &#8220;store&#8221; retrieves the whole result set, allocating memory for all rows and buffers them on the client side, whereas &#8220;use&#8221; doesn&#8217;t retrieve any rows at all &#8211; you need to use fetch_row to do row by row retrieval.</p>
<p>Anyways &#8211; glad I found your blog &#8211; keep it up!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Joey</title>
		<link>http://www.joeyrivera.com/2009/using-mysql-stored-procedures-with-php-mysqlmysqlipdo/comment-page-2/#comment-225</link>
		<dc:creator>Joey</dc:creator>
		<pubDate>Fri, 05 Feb 2010 14:43:10 +0000</pubDate>
		<guid isPermaLink="false">http://www.joeyrivera.com/?p=284#comment-225</guid>
		<description>I guess I was a bit too slow answering that first one. Thanks for providing the solution for others with this problem. I have had a few people with the same issue trying to do multiple queries.</description>
		<content:encoded><![CDATA[<p>I guess I was a bit too slow answering that first one. Thanks for providing the solution for others with this problem. I have had a few people with the same issue trying to do multiple queries.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Joey</title>
		<link>http://www.joeyrivera.com/2009/using-mysql-stored-procedures-with-php-mysqlmysqlipdo/comment-page-2/#comment-224</link>
		<dc:creator>Joey</dc:creator>
		<pubDate>Fri, 05 Feb 2010 14:38:54 +0000</pubDate>
		<guid isPermaLink="false">http://www.joeyrivera.com/?p=284#comment-224</guid>
		<description>DonM,

I believe the issus is the $qPicks-&gt;close(); inside your while. Basically you are closing the connection when returning your first result therefore you can&#039;t return any other results. I would first try commenting that line out (right after where you create your $symbol) and see if that fixes this. If not, let me know and I&#039;ll be glab to keep looking. Also, what error are you getting?</description>
		<content:encoded><![CDATA[<p>DonM,</p>
<p>I believe the issus is the $qPicks->close(); inside your while. Basically you are closing the connection when returning your first result therefore you can&#8217;t return any other results. I would first try commenting that line out (right after where you create your $symbol) and see if that fixes this. If not, let me know and I&#8217;ll be glab to keep looking. Also, what error are you getting?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: DonM</title>
		<link>http://www.joeyrivera.com/2009/using-mysql-stored-procedures-with-php-mysqlmysqlipdo/comment-page-2/#comment-219</link>
		<dc:creator>DonM</dc:creator>
		<pubDate>Fri, 05 Feb 2010 04:14:14 +0000</pubDate>
		<guid isPermaLink="false">http://www.joeyrivera.com/?p=284#comment-219</guid>
		<description>Got it figured and added example to PHP manual notes at http://us3.php.net/manual/en/mysqli.query.php - but probably won&#039;t show up there right away.

For others that are interested, hope this example helps...

// Connect to server and database
$mysqli		= new mysqli(&quot;$dbServer&quot;, &quot;$dbUser&quot;, &quot;$dbPass&quot;, &quot;$dbName&quot;);

// Open First Stored Procedure using MYSQLI_STORE_RESULT to retain for looping
$resultPicks = $mysqli-&gt;query(&quot;CALL $proc ($searchDate, $maxRSI, $incRSI, $minMACD, $minVol, $minTrades, $minClose, $maxClose)&quot;, MYSQLI_STORE_RESULT);

// process one row at a time from first SP
while($picksRow = $resultPicks-&gt;fetch_array(MYSQLI_ASSOC)) {
	// Get Parameter for next SP
	$symbol 	= $picksRow[&#039;Symbol&#039;];

	// Free stored results
	clearStoredResults($mysqli);

	// Execute second SP using value from first as a parameter (MYSQLI_USE_RESULT and free result right away)
	$resultData	= $mysqli-&gt;query(&quot;CALL prcGetLastMACDDatesBelowZero(&#039;$symbol&#039;, $searchDate)&quot;, MYSQLI_USE_RESULT);
	$dataRow	= $resultData-&gt;fetch_array(MYSQLI_ASSOC);

	// Dump result from both related queries
	echo &quot;$symbol ... Num Dates: &quot; . $dataRow[&#039;NumDates&#039;];

	// Free results from second SP
	$resultData-&gt;free();

}

// Free results from first SP
$resultPicks-&gt;free();

// close connections
$mysqli-&gt;close();

#------------------------------------------
function clearStoredResults($mysqli_link){
#------------------------------------------
    while($mysqli_link-&gt;next_result()){
      if($l_result = $mysqli_link-&gt;store_result()){
              $l_result-&gt;free();
      }
    }
}

?&gt;</description>
		<content:encoded><![CDATA[<p>Got it figured and added example to PHP manual notes at <a href="http://us3.php.net/manual/en/mysqli.query.php" rel="nofollow">http://us3.php.net/manual/en/mysqli.query.php</a> &#8211; but probably won&#8217;t show up there right away.</p>
<p>For others that are interested, hope this example helps&#8230;</p>
<p>// Connect to server and database<br />
$mysqli		= new mysqli(&#8220;$dbServer&#8221;, &#8220;$dbUser&#8221;, &#8220;$dbPass&#8221;, &#8220;$dbName&#8221;);</p>
<p>// Open First Stored Procedure using MYSQLI_STORE_RESULT to retain for looping<br />
$resultPicks = $mysqli-&gt;query(&#8220;CALL $proc ($searchDate, $maxRSI, $incRSI, $minMACD, $minVol, $minTrades, $minClose, $maxClose)&#8221;, MYSQLI_STORE_RESULT);</p>
<p>// process one row at a time from first SP<br />
while($picksRow = $resultPicks-&gt;fetch_array(MYSQLI_ASSOC)) {<br />
	// Get Parameter for next SP<br />
	$symbol 	= $picksRow['Symbol'];</p>
<p>	// Free stored results<br />
	clearStoredResults($mysqli);</p>
<p>	// Execute second SP using value from first as a parameter (MYSQLI_USE_RESULT and free result right away)<br />
	$resultData	= $mysqli-&gt;query(&#8220;CALL prcGetLastMACDDatesBelowZero(&#8216;$symbol&#8217;, $searchDate)&#8221;, MYSQLI_USE_RESULT);<br />
	$dataRow	= $resultData-&gt;fetch_array(MYSQLI_ASSOC);</p>
<p>	// Dump result from both related queries<br />
	echo &#8220;$symbol &#8230; Num Dates: &#8221; . $dataRow['NumDates'];</p>
<p>	// Free results from second SP<br />
	$resultData-&gt;free();</p>
<p>}</p>
<p>// Free results from first SP<br />
$resultPicks-&gt;free();</p>
<p>// close connections<br />
$mysqli-&gt;close();</p>
<p>#&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;<br />
function clearStoredResults($mysqli_link){<br />
#&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;<br />
    while($mysqli_link-&gt;next_result()){<br />
      if($l_result = $mysqli_link-&gt;store_result()){<br />
              $l_result-&gt;free();<br />
      }<br />
    }<br />
}</p>
<p>?&gt;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: DonM</title>
		<link>http://www.joeyrivera.com/2009/using-mysql-stored-procedures-with-php-mysqlmysqlipdo/comment-page-2/#comment-218</link>
		<dc:creator>DonM</dc:creator>
		<pubDate>Fri, 05 Feb 2010 03:11:15 +0000</pubDate>
		<guid isPermaLink="false">http://www.joeyrivera.com/?p=284#comment-218</guid>
		<description>Thanks for the article - just excellent.
I haven&#039;t found anything that can help me figure out how to call a new query inside original query result&#039;s loop.

Played with free_result and close, but no luck using mysqli. Queries work great individually, but not when I try to use another one back to back.

Do you have any ideas?

Here&#039;s the code that comes back with error now:

		// First find all matches
		$qPicks = $mysqli-&gt;query(&quot;CALL $proc ($searchDate, $maxRSI, $incRSI, $minMACD, $minVol, $minTrades, $minClose, $maxClose)&quot;);

		// process one row at a time
		while($pick = $qPicks-&gt;fetch_array(MYSQLI_ASSOC)) {
			$symbol = $pick[&#039;Symbol&#039;];
			$qPicks-&gt;close();

			$qData	= $mysqli-&gt;query(&quot;CALL prcGetLastMACDDatesBelowZero(&#039;$symbol&#039;, $searchDate)&quot;); //, MYSQLI_USE_RESULT
			$data 	= $qData-&gt;fetch_array(MYSQLI_ASSOC);
			echo &quot;$symbol ... Num Dates: &quot; . $data[&#039;NumDates&#039;];
			$qData-&gt;close();

		}

		// close connections
		$mysqli-&gt;close();

Thanks for any suggestions
Don</description>
		<content:encoded><![CDATA[<p>Thanks for the article &#8211; just excellent.<br />
I haven&#8217;t found anything that can help me figure out how to call a new query inside original query result&#8217;s loop.</p>
<p>Played with free_result and close, but no luck using mysqli. Queries work great individually, but not when I try to use another one back to back.</p>
<p>Do you have any ideas?</p>
<p>Here&#8217;s the code that comes back with error now:</p>
<p>		// First find all matches<br />
		$qPicks = $mysqli-&gt;query(&#8220;CALL $proc ($searchDate, $maxRSI, $incRSI, $minMACD, $minVol, $minTrades, $minClose, $maxClose)&#8221;);</p>
<p>		// process one row at a time<br />
		while($pick = $qPicks-&gt;fetch_array(MYSQLI_ASSOC)) {<br />
			$symbol = $pick['Symbol'];<br />
			$qPicks-&gt;close();</p>
<p>			$qData	= $mysqli-&gt;query(&#8220;CALL prcGetLastMACDDatesBelowZero(&#8216;$symbol&#8217;, $searchDate)&#8221;); //, MYSQLI_USE_RESULT<br />
			$data 	= $qData-&gt;fetch_array(MYSQLI_ASSOC);<br />
			echo &#8220;$symbol &#8230; Num Dates: &#8221; . $data['NumDates'];<br />
			$qData-&gt;close();</p>
<p>		}</p>
<p>		// close connections<br />
		$mysqli-&gt;close();</p>
<p>Thanks for any suggestions<br />
Don</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Joey Rivera</title>
		<link>http://www.joeyrivera.com/2009/using-mysql-stored-procedures-with-php-mysqlmysqlipdo/comment-page-2/#comment-74</link>
		<dc:creator>Joey Rivera</dc:creator>
		<pubDate>Mon, 04 Jan 2010 13:46:14 +0000</pubDate>
		<guid isPermaLink="false">http://www.joeyrivera.com/?p=284#comment-74</guid>
		<description>MuraliDharan, instead of using fetch_object try using fetch_array.This should give you the results you are looking for: http://us.php.net/manual/en/mysqli-result.fetch-array.php</description>
		<content:encoded><![CDATA[<p>MuraliDharan, instead of using fetch_object try using fetch_array.This should give you the results you are looking for: <a href="http://us.php.net/manual/en/mysqli-result.fetch-array.php" rel="nofollow">http://us.php.net/manual/en/mysqli-result.fetch-array.php</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: MuraliDharan</title>
		<link>http://www.joeyrivera.com/2009/using-mysql-stored-procedures-with-php-mysqlmysqlipdo/comment-page-2/#comment-73</link>
		<dc:creator>MuraliDharan</dc:creator>
		<pubDate>Sun, 03 Jan 2010 05:36:18 +0000</pubDate>
		<guid isPermaLink="false">http://www.joeyrivera.com/?p=284#comment-73</guid>
		<description>Hi,

It was really helpful.

My Query is ...is any way i can change the output array format

FROM

[
stdClass Object
(
[users_id] =&gt; 1
[first_name] =&gt; Joey
[last_name] =&gt; Rivera
)
stdClass Object
(
[users_id] =&gt; 2
[first_name] =&gt; John
[last_name] =&gt; Doe
)

]

TO

ARRAY
(
[users_id] =&gt; 1
[users_id] =&gt; 2
)

ARRAY
(
[first_name] =&gt; Joey
[first_name] =&gt; John
)

Thanks,
Dharan V</description>
		<content:encoded><![CDATA[<p>Hi,</p>
<p>It was really helpful.</p>
<p>My Query is &#8230;is any way i can change the output array format</p>
<p>FROM</p>
<p>[<br />
stdClass Object<br />
(<br />
[users_id] =&gt; 1<br />
[first_name] =&gt; Joey<br />
[last_name] =&gt; Rivera<br />
)<br />
stdClass Object<br />
(<br />
[users_id] =&gt; 2<br />
[first_name] =&gt; John<br />
[last_name] =&gt; Doe<br />
)</p>
<p>]</p>
<p>TO</p>
<p>ARRAY<br />
(<br />
[users_id] =&gt; 1<br />
[users_id] =&gt; 2<br />
)</p>
<p>ARRAY<br />
(<br />
[first_name] =&gt; Joey<br />
[first_name] =&gt; John<br />
)</p>
<p>Thanks,<br />
Dharan V</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jerick</title>
		<link>http://www.joeyrivera.com/2009/using-mysql-stored-procedures-with-php-mysqlmysqlipdo/comment-page-2/#comment-72</link>
		<dc:creator>Jerick</dc:creator>
		<pubDate>Fri, 18 Dec 2009 06:09:23 +0000</pubDate>
		<guid isPermaLink="false">http://www.joeyrivera.com/?p=284#comment-72</guid>
		<description>Hey Joey,
Thanks alot for your very much helpful blog . This helped me much  as I am just starting discovering  how SP  is helpful on us.
I did tried to search for a tutorial  but found nothing. Thanks finally, It is in here in your blog.

God bless You always and I&#039;ll be frequently visit your site to learn more.</description>
		<content:encoded><![CDATA[<p>Hey Joey,<br />
Thanks alot for your very much helpful blog . This helped me much  as I am just starting discovering  how SP  is helpful on us.<br />
I did tried to search for a tutorial  but found nothing. Thanks finally, It is in here in your blog.</p>
<p>God bless You always and I&#8217;ll be frequently visit your site to learn more.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Joey Rivera</title>
		<link>http://www.joeyrivera.com/2009/using-mysql-stored-procedures-with-php-mysqlmysqlipdo/comment-page-2/#comment-71</link>
		<dc:creator>Joey Rivera</dc:creator>
		<pubDate>Fri, 11 Dec 2009 21:36:02 +0000</pubDate>
		<guid isPermaLink="false">http://www.joeyrivera.com/?p=284#comment-71</guid>
		<description>Jick, once you have the data in the $row variable you can just call the item in the array to get the string value. For example, if you want to get the &#039;first_name&#039; you can do $echo $row[&#039;first_name&#039;] in the loop for each user to get their first name.</description>
		<content:encoded><![CDATA[<p>Jick, once you have the data in the $row variable you can just call the item in the array to get the string value. For example, if you want to get the &#8216;first_name&#8217; you can do $echo $row['first_name'] in the loop for each user to get their first name.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jick Libot</title>
		<link>http://www.joeyrivera.com/2009/using-mysql-stored-procedures-with-php-mysqlmysqlipdo/comment-page-1/#comment-70</link>
		<dc:creator>Jick Libot</dc:creator>
		<pubDate>Fri, 11 Dec 2009 03:18:05 +0000</pubDate>
		<guid isPermaLink="false">http://www.joeyrivera.com/?p=284#comment-70</guid>
		<description>This helps me a lot! Thanks bro! nway. I want to control the result by  in html, may i know how to convert the result to string?</description>
		<content:encoded><![CDATA[<p>This helps me a lot! Thanks bro! nway. I want to control the result by  in html, may i know how to convert the result to string?</p>
]]></content:encoded>
	</item>
</channel>
</rss>
