Re: PHP and ODBC leaving lots of files open

Chris Craig <[email protected]> Tue, 22 Jan 2013 08:57:28 -0500
Newsgroups gmane.comp.db.mdb-tools.devel
Message-ID <[email protected]>
I have limited experience with PHP, but maybe I can muddle through...

On 22/01/13 05:54 AM, Mike Prudence wrote:
 >      if (odbc_fetch_row($result))
 >         $retval = odbc_result($result, 'Name');
 >      else
 >         $retval = "Unknown";

What if there are more rows?

You should more likely do something like:

	if (odbc_fetch_row($result, 0))
		$retval = odbc_result($result, 'Name');
	else
		$retval = "Unknown";

	while(odbc_fetch_row($result)) {
		// do something with the extra results (or not)
	}

Or maybe you could call odbc_free_result before odbc_commit and odbc_close.

-- 
Chris Craig
Software Developer
Fibernetics Corp
605 Boxwood Dr
Cambridge ON  N3E 1A5
519-489-6700 x 753

------------------------------------------------------------------------------
Master Visual Studio, SharePoint, SQL, ASP.NET, C# 2012, HTML5, CSS,
MVC, Windows 8 Apps, JavaScript and much more. Keep your skills current
with LearnDevNow - 3,200 step-by-step video tutorials by Microsoft
MVPs and experts. ON SALE this month only -- learn more at:
http://p.sf.net/sfu/learnnow-d2d