freetds AT lists.ibiblio.org
Subject: FreeTDS Development Group
List archive
- From: "Thomas, Christopher (LLU)" <cwthomas AT llu.edu>
- To: "FreeTDS Development Group" <freetds AT lists.ibiblio.org>
- Subject: Re: [freetds] Multiple queries
- Date: Fri, 16 May 2008 08:31:11 -0700
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: freetds-bounces AT lists.ibiblio.org
[mailto:freetds-bounces AT lists.ibiblio.org] 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
FreeTDS AT lists.ibiblio.org
http://lists.ibiblio.org/mailman/listinfo/freetds
-
[freetds] Multiple queries,
Raymundo Perez, 05/16/2008
- Re: [freetds] Multiple queries, Thomas, Christopher (LLU), 05/16/2008
Archive powered by MHonArc 2.6.24.