From: Chris Wright Date: Sun, 7 Dec 2014 23:55:41 +0000 (+0000) Subject: Add Cursor::$flags property X-Git-Tag: v0.6.0RC1~7^2~1 X-Git-Url: https://git.m6w6.name/?a=commitdiff_plain;h=ed63ffdb6068a001a65a9e0e892079f97594afed;p=m6w6%2Fext-pq Add Cursor::$flags property --- diff --git a/src/php_pqconn.c b/src/php_pqconn.c index f2622d5..7d066c5 100644 --- a/src/php_pqconn.c +++ b/src/php_pqconn.c @@ -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); diff --git a/src/php_pqcur.c b/src/php_pqcur.c index fec703c..2df4f73 100644 --- a/src/php_pqcur.c +++ b/src/php_pqcur.c @@ -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; } diff --git a/src/php_pqcur.h b/src/php_pqcur.h index be44607..280db4a 100644 --- a/src/php_pqcur.h +++ b/src/php_pqcur.h @@ -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 {