Skip to Content.
Sympa Menu

freetds - [freetds] Multiple queries

freetds AT lists.ibiblio.org

Subject: FreeTDS Development Group

List archive

Chronological Thread  
  • From: "Raymundo Perez" <roskiy AT gmail.com>
  • To: "FreeTDS Development Group" <freetds AT lists.ibiblio.org>
  • Subject: [freetds] Multiple queries
  • Date: Fri, 16 May 2008 03:00:31 -0400

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($result,'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 ?>



Archive powered by MHonArc 2.6.24.

Top of Page