]> granicus.if.org Git - php/commitdiff
add theoretical support for returning ints as ints and bools as bools.
authorWez Furlong <wez@php.net>
Wed, 12 Jan 2005 03:26:46 +0000 (03:26 +0000)
committerWez Furlong <wez@php.net>
Wed, 12 Jan 2005 03:26:46 +0000 (03:26 +0000)
individual drivers need to support returning data in these formats.

ext/pdo/pdo_stmt.c
ext/pdo/php_pdo_driver.h

index 1e5db6d84face16e7ade91acc6f8307bcec21718..825b91b55bba3f7166166caa9dd4fe6b00766e4a 100755 (executable)
@@ -377,6 +377,22 @@ static inline void fetch_value(pdo_stmt_t *stmt, zval *dest, int colno TSRMLS_DC
        stmt->methods->get_col(stmt, colno, &value, &value_len TSRMLS_CC);
 
        switch (col->param_type) {
+               case PDO_PARAM_INT:
+                       if (value && value_len == sizeof(long)) {
+                               ZVAL_LONG(dest, *(long*)value);
+                               break;
+                       }
+                       ZVAL_NULL(dest);
+                       break;
+
+               case PDO_PARAM_BOOL:
+                       if (value && value_len == sizeof(zend_bool)) {
+                               ZVAL_BOOL(dest, *(zend_bool*)value);
+                               break;
+                       }
+                       ZVAL_NULL(dest);
+                       break;
+
                case PDO_PARAM_STR:
                        if (value && !(value_len == 0 && stmt->dbh->oracle_nulls)) {
                                ZVAL_STRINGL(dest, value, value_len, 1);
index bbfa7d36bf333e4e768ac6262dcbf815bf276364..87c2b0f187a931cdf01d2d9673faa58dc991faef 100755 (executable)
@@ -39,10 +39,11 @@ struct pdo_bound_param_data;
 
 enum pdo_param_type {
        PDO_PARAM_NULL,
-       PDO_PARAM_INT,
+       PDO_PARAM_INT,  /* int as in long, the php native int type */
        PDO_PARAM_STR,
        PDO_PARAM_LOB,
        PDO_PARAM_STMT, /* hierarchical result set */
+       PDO_PARAM_BOOL
 };
 
 enum pdo_fetch_type {
@@ -260,7 +261,10 @@ typedef int (*pdo_stmt_fetch_func)(pdo_stmt_t *stmt TSRMLS_DC);
  * Driver should populate stmt->columns[colno] with appropriate info */
 typedef int (*pdo_stmt_describe_col_func)(pdo_stmt_t *stmt, int colno TSRMLS_DC);
 
-/* retrieves pointer and size of the value for a column */
+/* retrieves pointer and size of the value for a column.
+ * Note that PDO expects the driver to manage the lifetime of this data;
+ * it will copy the value into a zval on behalf of the script.
+ */
 typedef int (*pdo_stmt_get_col_data_func)(pdo_stmt_t *stmt, int colno, char **ptr, unsigned long *len TSRMLS_DC);
 
 /* hook for bound params */
@@ -336,7 +340,7 @@ struct _pdo_dbh_t {
        /* these items mst appear in this order at the beginning of the
        struct so that this can be cast as a zend_object.  we need this
        to allow the extending class to escape all the custom handlers
-          that PDO decalres.
+          that PDO declares.
     */
        zend_class_entry *ce; 
        HashTable *properties;