From:             s dot sonnenberg at coolspot dot de
Operating system: Linux
PHP version:      4.3.2
PHP Bug Type:     MSSQL related
Bug description:  unknown column type "uniqueidentifier", type 35

Description:
------------
If you use the combination FreeTDS 0.61 + PHP 4.3.2 to access
data on a MS SQL Server 2000, columns of type "uniqueidentifier" (type 35)
or causing php to barf, and you are not able to handle them.
I got it to work after a applying a patch, that I figure out :

for ext/mssql/php_mssql.c :

--- php-4.3.2/ext/mssql/php_mssql.c     2003-05-21 02:06:41.000000000
+0200
+++ php-4.3.2-LOCAL/ext/mssql/php_mssql.c       2003-07-22
13:34:35.000000000 
+0200
@@ -800,6 +800,15 @@
                        Z_DVAL_P(result) = (double) floatcol8(offset);
                        Z_TYPE_P(result) = IS_DOUBLE;
                        break;
+               case SQLUNIQUE:
+                       {
+                               int length = 16;
+                               char *data = charcol(offset);
+                               Z_STRVAL_P(result) =
estrndup(data,length);
+                               Z_STRLEN_P(result) = length;
+                               Z_TYPE_P(result) = IS_STRING;
+                       }
+                       break;
                case SQLVARBINARY:
                case SQLBINARY:
                case SQLIMAGE: {

and for ext/mssql/php_mssql.h

--- php-4.3.2/ext/mssql/php_mssql.h     2003-02-09 08:49:34.000000000
+0100
+++ php-4.3.2-LOCAL/ext/mssql/php_mssql.h       2003-07-22
13:32:42.000000000 
+0200
@@ -32,7 +32,7 @@
 #endif
  
  
-#define MSSQL_VERSION "7.0"
+#define MSSQL_VERSION "8.0"
 #include "sqlfront.h"
 #include "sqldb.h"
  
@@ -59,6 +59,7 @@
 #define SQLIMAGE SYBIMAGE
 #define SQLBINARY SYBBINARY
 #define SQLVARBINARY SYBVARBINARY
+#define SQLUNIQUE SYBUNIQUE
 #define DBERRHANDLE(a, b) dberrhandle(b)
 #define DBMSGHANDLE(a, b) dbmsghandle(b)
 #define DBSETOPT(a, b, c) dbsetopt(a, b, c, -1)


It works for me :
RedHat 9.0 + updates
FreeTDS 0.61 (configure --prefix=/usr/local/freetds/0.61/ --enable-msdblib

--with-tdsver=8.0)
PHP 4.3.2 (configure --prefix=/usr/local/php/4.3.2/ 
--with-mssql=/usr/local/freetds/0.61/ --without-mysql)
Windows 2000 BackOffice Server SP 4 + MS SQL Server 2000 SP 3

Perhaps +#define MSSQL_VERSION "8.0" is a bit "heavy", but looks nicer in

phpinfo() ...

You can test it, if you fetch such a field, and then pass that value to
mssql_guid_string. The output must be equal to CAST (field as CHAR(64)),
where field is of the uniqueidentifier type.



Reproduce code:
---------------
$sql = "select * from tablename";
$res = mssql_query($sql);


/* causes php to barf, if you have a field of type uniqueidentifier */


-- 
Edit bug report at http://bugs.php.net/?id=24752&edit=1
-- 
Try a CVS snapshot (php4):  http://bugs.php.net/fix.php?id=24752&r=trysnapshot4
Try a CVS snapshot (php5):  http://bugs.php.net/fix.php?id=24752&r=trysnapshot5
Fixed in CVS:               http://bugs.php.net/fix.php?id=24752&r=fixedcvs
Fixed in release:           http://bugs.php.net/fix.php?id=24752&r=alreadyfixed
Need backtrace:             http://bugs.php.net/fix.php?id=24752&r=needtrace
Try newer version:          http://bugs.php.net/fix.php?id=24752&r=oldversion
Not developer issue:        http://bugs.php.net/fix.php?id=24752&r=support
Expected behavior:          http://bugs.php.net/fix.php?id=24752&r=notwrong
Not enough info:            http://bugs.php.net/fix.php?id=24752&r=notenoughinfo
Submitted twice:            http://bugs.php.net/fix.php?id=24752&r=submittedtwice
register_globals:           http://bugs.php.net/fix.php?id=24752&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=24752&r=php3
Daylight Savings:           http://bugs.php.net/fix.php?id=24752&r=dst
IIS Stability:              http://bugs.php.net/fix.php?id=24752&r=isapi
Install GNU Sed:            http://bugs.php.net/fix.php?id=24752&r=gnused

Reply via email to