Add Cursor::$flags property
authorChris Wright <github@daverandom.com>
Sun, 7 Dec 2014 23:55:41 +0000 (23:55 +0000)
committerChris Wright <daverandom@php.net>
Mon, 15 Dec 2014 15:12:14 +0000 (15:12 +0000)
src/php_pqconn.c
src/php_pqcur.c
src/php_pqcur.h

index f2622d5..7d066c5 100644 (file)
@@ -1410,6 +1410,7 @@ static PHP_METHOD(pqconn, declare) {
                                cur->open = 1;
                                cur->name = estrdup(name_str);
                                cur->decl = decl;
+                               cur->flags = flags;
 
                                return_value->type = IS_OBJECT;
                                return_value->value.obj = php_pqcur_create_object_ex(php_pqcur_class_entry, cur, NULL TSRMLS_CC);
index fec703c..2df4f73 100644 (file)
@@ -207,6 +207,13 @@ static void php_pqcur_object_read_connection(zval *object, void *o, zval *return
        php_pq_object_to_zval(obj->intern->conn, &return_value TSRMLS_CC);
 }
 
+static void php_pqcur_object_read_flags(zval *object, void *o, zval *return_value TSRMLS_DC)
+{
+       php_pqcur_object_t *obj = o;
+
+       RETVAL_LONG(obj->intern->flags);
+}
+
 char *php_pqcur_declare_str(const char *name_str, size_t name_len, unsigned flags, const char *query_str, size_t query_len)
 {
        size_t decl_len = name_len + query_len + sizeof("DECLARE  BINARY INSENSITIVE NO SCROLL CURSOR WITH HOLD FOR ");
@@ -272,6 +279,7 @@ static PHP_METHOD(pqcur, __construct) {
                                cur->open = 1;
                                cur->name = estrdup(name_str);
                                cur->decl = decl;
+                               cur->flags = flags;
                                obj->intern = cur;
                        }
                }
@@ -423,6 +431,10 @@ PHP_MINIT_FUNCTION(pqcur)
        ph.read = php_pqcur_object_read_connection;
        zend_hash_add(&php_pqcur_object_prophandlers, "connection", sizeof("connection"), (void *) &ph, sizeof(ph), NULL);
 
+       zend_declare_property_null(php_pqcur_class_entry, ZEND_STRL("flags"), ZEND_ACC_PUBLIC TSRMLS_CC);
+       ph.read = php_pqcur_object_read_flags;
+       zend_hash_add(&php_pqcur_object_prophandlers, "flags", sizeof("flags"), (void *) &ph, sizeof(ph), NULL);
+
        return SUCCESS;
 }
 
index be44607..280db4a 100644 (file)
@@ -27,6 +27,7 @@ typedef struct php_pqcur {
        char *name;
        char *decl;
        unsigned open:1;
+       long flags;
 } php_pqcur_t;
 
 typedef struct php_pqcur_object {