Re: Multiple queries
"Thomas, Christopher (LLU)" <[email protected]>
| Newsgroups | gmane.comp.db.tds.freetds |
|---|---|
| Message-ID | <6B9B0CEF7F409D439E78288D8665BD8F3418C8@oakmont.llu.ad.lluahsc.org> |
Hello, After you get the results for your query, you should free the results. http://us3.php.net/manual/en/function.odbc-free-result.php I got the same error with PHP until I freed the results. Chris -----Original Message----- From: [email protected] [mailto:[email protected]] On Behalf Of Raymundo Perez Sent: Friday, May 16, 2008 12:01 AM To: FreeTDS Development Group Subject: [freetds] Multiple queries Using Linux ubuntu; apache2;PHP; unix-ODBC; I recursively call function that create an odbc connection via FreeTDS driver after function recursively call itself i receive following error: *Warning*: odbc_exec() [function.odbc-exec <https://inside.oceanrock-dr.com/function.odbc-exec>]: SQL error: ????., SQL state 00000 in SQLExecDirect in */var/www/scriptname.php* as i understood new connection is not being created on odbc_connect call but old connection and cursor is reused. proved it adding odbc_close_all(); statement in the begining of the function tried same script runing on windows OS System using native Microsfot SQL drivers for ODBC and script worked fine 1<?php 2 include_once('ps.php'); //just setting up constants connection_string, db_user, db_pass 3 4 function DoNode($parent = 0) 5 { 6 $sql="Select field1,field2,field3 from table1 where somefield=$parent"; 7 $conn = odbc_connect( connection_string, db_user, db_pass, SQL_CUR_USE_ODBC); 8 $result=odbc_exec($conn, $sql) or die (odbc_errormsg().'<br />'.$sql); 9 while (odbc_fetch_row($result)) 10 { 11 if (odbc_result($result,'CallString')=='#') 12 $res.='<li>'.odbc_result($result,'field1').'<ul>'.DoNode(odbc_result($re sult,'field2')).'</ul></li>'; // <- NOTE recursive call here 13 else 14 $res.='<li><a href="'.odbc_result($result,'field3').'">'.odbc_result($result,'field1') .'</a></li>'; 15 } 16 //end of function 17 return $res; 18 } 19 echo DoNode(); 20 ?> _______________________________________________ FreeTDS mailing list [email protected] http://lists.ibiblio.org/mailman/listinfo/freetds