felipe                                   Sat, 05 Mar 2011 23:07:45 +0000

Revision: http://svn.php.net/viewvc?view=revision&revision=308948

Log:
- Fixed bug #54167 (PDO_DBLIB returns null on SQLUNIQUE field)
# initial patch by: mjh at hodginsmedia dot com (5.3)
# trunk version by me

Bug: http://bugs.php.net/54167 (Open) PDO_DBLIB returns null on SQLUNIQUE field
      
Changed paths:
    U   php/php-src/branches/PHP_5_3/NEWS
    U   php/php-src/branches/PHP_5_3/ext/pdo_dblib/dblib_stmt.c
    U   php/php-src/trunk/ext/pdo_dblib/dblib_stmt.c

Modified: php/php-src/branches/PHP_5_3/NEWS
===================================================================
--- php/php-src/branches/PHP_5_3/NEWS   2011-03-05 22:32:53 UTC (rev 308947)
+++ php/php-src/branches/PHP_5_3/NEWS   2011-03-05 23:07:45 UTC (rev 308948)
@@ -1,6 +1,9 @@
 ´╗┐PHP                                                                        
NEWS
 |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
 ?? ??? 2011, PHP 5.3.6
+- PDO DBLib driver:
+  . Fixed bug #54167 (PDO_DBLIB returns null on SQLUNIQUE field).
+    (mjh at hodginsmedia dot com, Felipe)

 03 Mar 2011, PHP 5.3.6RC2
 - Zend Engine:

Modified: php/php-src/branches/PHP_5_3/ext/pdo_dblib/dblib_stmt.c
===================================================================
--- php/php-src/branches/PHP_5_3/ext/pdo_dblib/dblib_stmt.c     2011-03-05 
22:32:53 UTC (rev 308947)
+++ php/php-src/branches/PHP_5_3/ext/pdo_dblib/dblib_stmt.c     2011-03-05 
23:07:45 UTC (rev 308948)
@@ -25,6 +25,7 @@

 #include "php.h"
 #include "php_ini.h"
+#include "ext/standard/php_string.h"
 #include "ext/standard/info.h"
 #include "pdo/php_pdo.h"
 #include "pdo/php_pdo_driver.h"
@@ -67,7 +68,6 @@

 static int pdo_dblib_stmt_execute(pdo_stmt_t *stmt TSRMLS_DC)
 {
-       pdo_dbh_t *dbh = stmt->dbh;
        pdo_dblib_stmt *S = (pdo_dblib_stmt*)stmt->driver_data;
        pdo_dblib_db_handle *H = S->H;
        RETCODE resret, ret;
@@ -174,6 +174,23 @@
                                                val->len = spprintf(&val->data, 
0, "%.4f", money_value);
                                                }
                                                break;
+#ifdef SQLUNIQUE
+                                        case SQLUNIQUE: {
+#else
+                                        case 36: { /* FreeTDS hack, also used 
by ext/mssql */
+#endif
+                                                val->len = 36+1;
+                                                val->data = emalloc(val->len + 
1);
+
+                                                /* uniqueidentifier is a 
16-byte binary number, convert to 32 char hex string */
+#ifdef SQLUNIQUE
+                                                val->len = dbconvert(NULL, 
SQLUNIQUE, dbdata(H->link, i+1), dbdatlen(H->link, i+1), SQLCHAR, val->data, 
val->len);
+#else
+                                                val->len = dbconvert(NULL, 36, 
dbdata(H->link, i+1), dbdatlen(H->link, i+1), SQLCHAR, val->data, val->len);
+#endif
+                                                php_strtoupper(val->data, 
val->len);
+                                                break;
+                                        }
                                        default:
                                                if 
(dbwillconvert(S->cols[i].coltype, SQLCHAR)) {
                                                        val->len = 32 + (2 * 
dbdatlen(H->link, i+1));

Modified: php/php-src/trunk/ext/pdo_dblib/dblib_stmt.c
===================================================================
--- php/php-src/trunk/ext/pdo_dblib/dblib_stmt.c        2011-03-05 22:32:53 UTC 
(rev 308947)
+++ php/php-src/trunk/ext/pdo_dblib/dblib_stmt.c        2011-03-05 23:07:45 UTC 
(rev 308948)
@@ -25,6 +25,7 @@

 #include "php.h"
 #include "php_ini.h"
+#include "ext/standard/php_string.h"
 #include "ext/standard/info.h"
 #include "pdo/php_pdo.h"
 #include "pdo/php_pdo_driver.h"
@@ -224,6 +225,24 @@
                        *ptr = tmp_ptr;
                        break;
                }
+#ifdef SQLUNIQUE
+               case SQLUNIQUE: {
+#else
+               case 36: { /* FreeTDS hack, also used by ext/mssql */
+#endif
+                       *len = 36+1;
+                       tmp_ptr = emalloc(*len + 1);
+
+                       /* uniqueidentifier is a 16-byte binary number, convert 
to 32 char hex string */
+#ifdef SQLUNIQUE
+                       *len = dbconvert(NULL, SQLUNIQUE, ptr, *len, SQLCHAR, 
tmp_ptr, *len);
+#else
+                       *len = dbconvert(NULL, 36, ptr, *len, SQLCHAR, tmp_ptr, 
*len);
+#endif
+                       php_strtoupper(tmp_ptr, *len);
+                       *ptr = tmp_ptr;
+                       break;
+               }
                default:
                        if (dbwillconvert(coltype, SQLCHAR)) {
                                tmp_len = 32 + (2 * (*len));

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to