php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #21076 ODBC_TABLES and ODBC_COLUMNS cannot be called together
Submitted: 2002-12-18 07:54 UTC Modified: 2004-04-21 00:13 UTC
Votes:6
Avg. Score:4.5 ± 0.8
Reproduced:6 of 6 (100.0%)
Same Version:3 (50.0%)
Same OS:2 (33.3%)
From: jlim at natsoft dot com Assigned:
Status: No Feedback Package: ODBC related
PHP Version: 4CVS, 5CVS OS: Win2000, IIS-CGI
Private report: No CVE-ID: None
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: jlim at natsoft dot com
New email:
PHP Version: OS:

 

 [2002-12-18 07:54 UTC] jlim at natsoft dot com
The following code:
<?php
error_reporting(E_ALL);

$conn = odbc_connect("netsdk", "yyyy", "xxxx") or die("FAIL CONNECTION");
print "Connected <br>";
print "ODBC_Tables<br>"; 
	$trs = odbc_tables($conn); 
	odbc_free_result($trs);
print "ODBC_Columns<br>"; 
	$colrs = odbc_columns($conn); 
	odbc_free_result($colrs);
print "Done<br>";
?>

Will generate the output:

Connected 
ODBC_Tables
ODBC_Columns

Warning: SQL error: , SQL state 00000 in SQLColumns in d:\inetpub\wwwroot\php\hs~a.php on line 10

Warning: odbc_free_result(): supplied argument is not a valid ODBC result resource in d:\inetpub\wwwroot\php\hs~a.php on line 11
Done

However, the following code with odbc_tables commented out:

<?php
error_reporting(E_ALL);

$conn = odbc_connect("netsdk", "adodb", "natsoft") or die("FAIL CONNECTION");
print "Connected <br>";
/*print "ODBC_Tables<br>"; 
	$trs = odbc_tables($conn); 
	odbc_free_result($trs);*/
print "ODBC_Columns<br>"; 
	$colrs = odbc_columns($conn); 
	odbc_free_result($colrs);
print "Done<br>";
?>

Works fine with the output:

Connected 
ODBC_Columns
Done

Hope this was clear.

Regards, John Lim

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2003-01-24 16:18 UTC] kalowsky@php.net
Marking as bogus.  

Using Win2k, and the CGI build I cannot reproduce this at all.  My attempts to showed nothing wrong with the code base that I could find.  
 [2003-01-25 09:39 UTC] heyjohnlim at yahoo dot com
Hi

Thanks for testing. I just retested.


When i test with MS Access driver the problem does not occur. 

In the original report, I tested on microsoft sql server 2000, with SQL Server ODBC Driver version 2000.81.9001.00 (MDAC 2.6 installed).  I just retested and still get the problem. I set the "Use ANSI quoted identifiers" and "Use ANSI nulls" in the odbc driver.

- John
 [2003-01-26 16:10 UTC] kalowsky@php.net
Update your MDAC to 2.7 it's the latest and from what I can tell works fine.  I have no SQL-Server to test on though unfortunately.  
 [2003-02-15 23:00 UTC] heyjohnlim at yahoo dot com
I have updated to MDAC 2.7 and it still happens. Perhaps it is due to mssql driver issues.

Regards, John
 [2003-02-18 12:05 UTC] kalowsky@php.net
I looked into this a but more this past week... I still don't see anything outrageously wrong.  Very odd... any chance I can get you to try this script with a lame DB like MS Access?  

I still am unable to reproduce this locally.
 [2003-02-18 23:34 UTC] heyjohnlim at yahoo dot com
Sorry I forgot to mention, i did test on access previously and it was ok. The mssql odbc driver is probably much more complex.
 [2003-02-19 23:35 UTC] kalowsky@php.net
Well now that seems really odd.  I guess I'll have to try to get access to a SQLServer machine for some testing... ugh...
 [2003-06-29 22:45 UTC] kalowsky@php.net
Yep it exists.
 [2003-07-02 04:01 UTC] jlim at natsoft dot com
Tested with 4.3.3RC2-dev. Same problem with mssql odbc driver.

I also tested with access and oracle odbc drivers and the problem never happens with these drivers, so it appears to be something specific to the way mssql does things.

I also double-checked the MDAC using M'soft's ComCheck program(as i have changed PC's), and it is mdac 2.7 SP1.

The mssql driver version is 2000.81.9031.14, 15/Nov/2002

Regards, John
 [2004-04-21 00:13 UTC] iliaa@php.net
No feedback was provided. The bug is being suspended because
we assume that you are no longer experiencing the problem.
If this is not the case and you are able to provide the
information that was requested earlier, please do so and
change the status of the bug back to "Open". Thank you.


 [2007-12-27 05:21 UTC] php-louis at steelbytes dot com
I just ran into this problem with latest PHP and MSDE2000 (SQL Server 2000 cut down editon).

using somthing like the following does not work ... (pseudo code)

$tables = odbc_tables($con)
while ($t=$odbc_fetch_array($tables))
{
  odbc_columns($con,$t['TABLE_CAT'],$t['TABLE_SCHEM'],$t['TABLE_NAME']); <-- fails here
  display column results
}

but the following does work

$tables = odbc_tables($con)
while ($t=$odbc_fetch_array($tables))
  array_push($tahbles_array,$t);
odbc_free_result($tables);
for (. $t in $tahbles_array .)
{
  odbc_columns(..$t[name].) (as above) 
  display column results
  odbc_free_result()
}
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Wed Oct 09 11:01:27 2024 UTC