summaryrefslogtreecommitdiff
path: root/src/valueiterator.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/valueiterator.cpp')
-rw-r--r--src/valueiterator.cpp25
1 files changed, 24 insertions, 1 deletions
diff --git a/src/valueiterator.cpp b/src/valueiterator.cpp
index a40ff81..08520d5 100644
--- a/src/valueiterator.cpp
+++ b/src/valueiterator.cpp
@@ -91,13 +91,36 @@ ValueIterator &ValueIterator::read()
{
// zval to read the current key in
Value key;
-
+
+#if PHP_VERSION_ID >= 50500
+
// read in the current key
zend_hash_get_current_key_zval_ex(_table, key._val, &_position);
// if the key is set to NULL, it means that the object is not at a valid position
if (key.isNull()) return invalidate();
+#else
+
+ // php 5.3 and php 5.4 need a different implementation because the function
+ // zend_hash_get_current_key_zval_ex is missing in php 5.3, declare variables
+ // we need for storing the key in
+ char *string_key;
+ unsigned int str_len;
+ unsigned long num_key;
+
+ // get the current key
+ int type = zend_hash_get_current_key_ex(_table, &string_key, &str_len, &num_key, 0, &_position);
+
+ // if key is not found, the iterator is at an invalid position
+ if (type == HASH_KEY_NON_EXISTANT) return invalidate();
+
+ // numeric keys are the easiest ones
+ if (type == HASH_KEY_NON_EXISTANT) key = (int64_t)num_key;
+ else key = string_key;
+
+#endif
+
// iterator is at a valid position, go fetch the data
// this is the variable we need for fetching the data
zval **value;