Re: cvs: php4 /ext/mssql php_mssql.c

From: Date: Tue, 01 May 2001 18:15:20 +0000
Subject: Re: cvs: php4 /ext/mssql php_mssql.c
References: 1  Groups: php.cvs 
Request: Send a blank email to php-cvs+get-5437@lists.php.net to get a copy of this message
Frank, I optimized the code a bit so please check that it still works. I can't test it here. Thanks, Andi At 06:01 PM 5/1/2001 +0000, Frank M. Kromann wrote:
fmk             Tue May  1 11:01:08 2001 EDT
Modified files:
    /php4/ext/mssql     php_mssql.c
Log: Adding support for BINARY, VARBINARY and IMAGE column types. Thanks to Brad LaFountain. Index: php4/ext/mssql/php_mssql.c diff -u php4/ext/mssql/php_mssql.c:1.40 php4/ext/mssql/php_mssql.c:1.41
--- php4/ext/mssql/php_mssql.c:1.40     Tue Mar 13 08:33:39 2001
+++ php4/ext/mssql/php_mssql.c Tue May 1 11:01:08 2001 @@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
*/ -/* $Id: php_mssql.c,v 1.40 2001/03/13 16:33:39 fmk Exp $ */ +/* $Id: php_mssql.c,v 1.41 2001/05/01 18:01:08 fmk Exp $ */ #ifdef COMPILE_DL_MSSQL #define HAVE_MSSQL 1 @@ -729,6 +729,22 @@
                        result->type = IS_DOUBLE;
                        break;
                }
+               case SQLVARBINARY:
+               case SQLBINARY:
+               case SQLIMAGE: {
+                       DBBINARY *bin;
+                       unsigned char *res_buf;
+                       int res_length = dbdatlen(mssql_ptr->link,offset);
+
+                       res_buf = (unsigned char *) emalloc(res_length);
+                       memset(res_buf, 0, res_length);
+                       bin = ((DBBINARY *)dbdata(mssql_ptr->link,offset));
+                       memcpy(res_buf,bin,res_length);
+                       result->value.str.len = res_length;
+                       result->value.str.val = res_buf;
+                       result->type = IS_STRING;
+                       }
+                       break;
                case SQLNUMERIC:
                default: {
                        if (dbwillconvert(column_type,SQLCHAR)) {
@@ -759,7 +775,22 @@
                return;
        }
-       if (dbwillconvert(coltype(offset),SQLCHAR)) {
+       if (column_type == SQLVARBINARY ||
+               column_type == SQLBINARY ||
+               column_type == SQLIMAGE) {
+               DBBINARY *bin;
+               unsigned char *res_buf;
+               int res_length = dbdatlen(mssql_ptr->link,offset);
+
+               res_buf = (unsigned char *) emalloc(res_length);
+               memset(res_buf, 0, res_length);
+               bin = ((DBBINARY *)dbdata(mssql_ptr->link,offset));
+               memcpy(res_buf,bin,res_length);
+               result->value.str.len = res_length;
+               result->value.str.val = res_buf;
+               result->type = IS_STRING;
+       }
+       else if  (dbwillconvert(coltype(offset),SQLCHAR)) {
                unsigned char *res_buf;
                int res_length = dbdatlen(mssql_ptr->link,offset);
-- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, e-mail: php-cvs-unsubscribe@lists.php.net For additional commands, e-mail: php-cvs-help@lists.php.net To contact the list administrators, e-mail: php-list-admin@lists.php.net


« previous php.cvs (#5437) next »