<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://blogs.msdn.com/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Microsoft SQL Server Driver for PHP Team Blog : Field count</title><link>http://blogs.msdn.com/sqlphp/archive/tags/Field+count/default.aspx</link><description>Tags: Field count</description><dc:language>en-US</dc:language><generator>CommunityServer 2.1 SP1 (Build: 61025.2)</generator><item><title>Functions to return row count and field count</title><link>http://blogs.msdn.com/sqlphp/archive/2008/03/05/functions-to-return-row-count-and-field-count.aspx</link><pubDate>Thu, 06 Mar 2008 03:50:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8075631</guid><dc:creator>dpblogs</dc:creator><slash:comments>15</slash:comments><comments>http://blogs.msdn.com/sqlphp/comments/8075631.aspx</comments><wfw:commentRss>http://blogs.msdn.com/sqlphp/commentrss.aspx?PostID=8075631</wfw:commentRss><description>&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;It’s great to see that people are downloading our the February CTP build of our PHP driver and that we’re getting feedback on our new features.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;We look forward to more of your feedback and we’re in the process of setting up a new forum specifically for questions and feedback for the PHP driver.&lt;?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;A lot of the feedback has centered around requests for a num_rows function for the PHP driver.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;In our PHP driver, we’re using the most performant way to retrieve the results of a SQL Server query, a forward-only read-only stream of data.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;With this approach there’s no way for the driver to know how the total number of rows that the query will return until you’ve finished processing the results of the query.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;We could offer a num_rows function but without providing buffered resultsets, that num_rows function would only return the number of rows returned so far.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;While that appears to be a fairly standard behavior for drivers that don’t support buffered resultsets, it doesn’t strike me as adding a great deal of value.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;With that said, I’m curious as to whether there’s real interest in a num_rows function without adding support for buffered resultsets?&lt;o:p&gt;&lt;/o:p&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;We are planning on adding a function to return the number of fields in a resultset later in this release.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;There’s a simple workaround in the meantime – use the count function in conjunction with sqlsrv_field_metadata:&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;o:p&gt;&lt;/o:p&gt;&amp;nbsp;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; TEXT-INDENT: 0.5in"&gt;&lt;SPAN style="FONT-SIZE: 9pt; FONT-FAMILY: 'Courier New'"&gt;$fieldCount = count(sqlsrv_field_metadata($stmt));&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; TEXT-INDENT: 0.5in"&gt;&lt;SPAN style="FONT-SIZE: 9pt; FONT-FAMILY: 'Courier New'"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&amp;nbsp;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;The main benefit in adding a function to return this information is that returning the number of fields without generating the field metadata would be more performant.&lt;o:p&gt;&lt;/o:p&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt" mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;David Sceppa&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;Program Manager, SQL Server Driver for PHP&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=8075631" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/sqlphp/archive/tags/PHP/default.aspx">PHP</category><category domain="http://blogs.msdn.com/sqlphp/archive/tags/Design/default.aspx">Design</category><category domain="http://blogs.msdn.com/sqlphp/archive/tags/Row+count/default.aspx">Row count</category><category domain="http://blogs.msdn.com/sqlphp/archive/tags/Field+count/default.aspx">Field count</category></item></channel></rss>