From: ben dot crum at colony101uk dot com
Operating system: Windows XP SP2
PHP version: 5.2.2
PHP Bug Type: COM related
Bug description: ADODB.Recordset ActiveConnection property - can't set with
PHP 5.2.1+
Description:
------------
This seems similar to Bug #22162 - Program performs "illegal operation",
but that was for PHP 4.3.1-dev.
I originally had PHP 5.1.6 installed on my PC and had written a few
scripts using ADODB Connections and Recordsets. These ran fine as web
pages served by Apache's HTTP Server v2.0.
I upgraded to PHP 5.2.2 using the MSI and my scripts reported errors for
the same line of code.
Overwriting the contents of my C:\PHP\ folder with the contents of the PHP
5.2.0 Zip file, I do NOT get these errors when running my scripts as web
pages through Apache or from the command line (i.e. "php.exe
c:\Web\simple.php").
If I overwrite the contents of my C:\PHP\ folder with the PHP 5.2.1 or
5.2.2 Zip files I get the error mentioned above when running them through
Apache or from the command line.
Reproduce code:
---------------
Here is a simple sample that works with PHP 5.2.0, but breaks for me when
using PHP 5.2.1+:
------------------------------
<?php
$rs = new COM('ADODB.Recordset');
// Problem line below for PHP 5.2.1+:
$rs->ActiveConnection = 'PROVIDER=SQLOLEDB; DATA SOURCE=(local); UID=sa;
PWD=password; INITIAL CATALOG=myDB';
$rs->CursorLocation = 3;
$rs->Source = 'SELECT * FROM [myTable]';
$rs->Open();
if ( $rs->EoF )
{
print( '- No records returned. -' );
}
else
{
print( 'Returned records: ' . $rs->RecordCount );
}
$rs->Close();
$rs = NULL;
?>
------------------------------
Expected result:
----------------
This is the error I get on lines that set an ADODB.Recordset object's
.ActiveConnection property:
Fatal error: Uncaught exception 'com_exception' with message
'<b>Source:</b> Provider<br/><b>Description:</b> Type mismatch.' in
C:\Web\simple.php:4 Stack trace: #0 C:\Web\simple.php(4): unknown() #1
{main} thrown in C:\Web\simple.php on line 4
Actual result:
--------------
I don't think it's the objects and their properties coz this works as a
VBScript (.vbs) file (no hissing please!):
------------------------------
OPTION EXPLICIT
DIM rs
SET rs = CreateObject("ADODB.Recordset")
rs.ActiveConnection = "PROVIDER=SQLOLEDB; DATA SOURCE=(local); UID=sa;
PWD=password; INITIAL CATALOG=myDB"
rs.CursorLocation = 3
rs.Source = "SELECT * FROM [myTable]"
rs.Open
IF ( rs.EoF ) THEN
WScript.Echo( "- No records returned. -" )
ELSE
WScript.Echo( "Returned records: " & rs.RecordCount )
END IF
rs.Close
SET rs = Nothing
------------------------------
It looks to me that after 5.2.0, PHP no longer lets you set the
.ActiveConnection of an ADODB.Recordset (or I've just messed up my PHP
folder...).
Thanks for your help.
--
Edit bug report at http://bugs.php.net/?id=41368&edit=1
--
Try a CVS snapshot (PHP 4.4):
http://bugs.php.net/fix.php?id=41368&r=trysnapshot44
Try a CVS snapshot (PHP 5.2):
http://bugs.php.net/fix.php?id=41368&r=trysnapshot52
Try a CVS snapshot (PHP 6.0):
http://bugs.php.net/fix.php?id=41368&r=trysnapshot60
Fixed in CVS: http://bugs.php.net/fix.php?id=41368&r=fixedcvs
Fixed in release:
http://bugs.php.net/fix.php?id=41368&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=41368&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=41368&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=41368&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=41368&r=support
Expected behavior: http://bugs.php.net/fix.php?id=41368&r=notwrong
Not enough info:
http://bugs.php.net/fix.php?id=41368&r=notenoughinfo
Submitted twice:
http://bugs.php.net/fix.php?id=41368&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=41368&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=41368&r=php3
Daylight Savings: http://bugs.php.net/fix.php?id=41368&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=41368&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=41368&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=41368&r=float
No Zend Extensions: http://bugs.php.net/fix.php?id=41368&r=nozend
MySQL Configuration Error: http://bugs.php.net/fix.php?id=41368&r=mysqlcfg