Skip to content

Commit 28a6f21

Browse files
committed
php 5.4 suppert
1 parent 2c64018 commit 28a6f21

File tree

4 files changed

+17
-7
lines changed

4 files changed

+17
-7
lines changed

.travis.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ addons:
1616
- clickhouse
1717

1818
php:
19+
- 5.4
1920
- 5.5
2021
- 5.6
2122
- 7.0

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ PHP client for [Yandex ClickHouse](https://clickhouse.yandex/),Based on [Click
2323
* UInt8, UInt16, UInt32, UInt64, Int8, Int16, Int32, Int64
2424

2525
## Supported PHP version
26-
PHP 5.5+
26+
PHP 5.4+
2727

2828
## Performance
2929
![image](https://github.com/SeasX/SeasClick/raw/master/tests/bench_mark/bench_mark.png)

SeasClick.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,7 @@ PHP_METHOD(SEASCLICK_RES_NAME, __construct)
257257
clientMap.insert(std::pair<int, Client*>(key, client));
258258

259259
} catch (const std::exception& e) {
260-
zend_throw_exception(NULL, e.what(), 0 TSRMLS_CC);
260+
sc_zend_throw_exception(NULL, e.what(), 0 TSRMLS_CC);
261261
}
262262

263263
RETURN_TRUE;
@@ -356,7 +356,7 @@ PHP_METHOD(SEASCLICK_RES_NAME, select)
356356
);
357357

358358
} catch (const std::exception& e) {
359-
zend_throw_exception(NULL, e.what(), 0 TSRMLS_CC);
359+
sc_zend_throw_exception(NULL, e.what(), 0 TSRMLS_CC);
360360
}
361361
}
362362
/* }}} */
@@ -451,7 +451,7 @@ PHP_METHOD(SEASCLICK_RES_NAME, insert)
451451
sc_zval_ptr_dtor(&return_should);
452452

453453
} catch (const std::exception& e) {
454-
zend_throw_exception(NULL, e.what(), 0 TSRMLS_CC);
454+
sc_zend_throw_exception(NULL, e.what(), 0 TSRMLS_CC);
455455
}
456456
RETURN_TRUE;
457457
}
@@ -507,7 +507,7 @@ PHP_METHOD(SEASCLICK_RES_NAME, execute)
507507
client->Execute(sql_s);
508508

509509
} catch (const std::exception& e) {
510-
zend_throw_exception(NULL, e.what(), 0 TSRMLS_CC);
510+
sc_zend_throw_exception(NULL, e.what(), 0 TSRMLS_CC);
511511
}
512512
RETURN_TRUE;
513513
}
@@ -524,7 +524,7 @@ PHP_METHOD(SEASCLICK_RES_NAME, __destruct)
524524
clientMap.erase(key);
525525

526526
} catch (const std::exception& e) {
527-
zend_throw_exception(NULL, e.what(), 0 TSRMLS_CC);
527+
sc_zend_throw_exception(NULL, e.what(), 0 TSRMLS_CC);
528528
}
529529
RETURN_TRUE;
530530
}

php7_wrapper.h

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,13 @@
1717
*/
1818
// PHP7+
1919
#if PHP_MAJOR_VERSION < 7
20+
21+
#if PHP_VERSION_ID < 50500
22+
#define sc_zend_throw_exception(a, b, c) zend_throw_exception(a, (char *)b, c)
23+
#else
24+
#define sc_zend_throw_exception zend_throw_exception
25+
#endif
26+
2027
#define IS_TRUE 1
2128
#define SC_MAKE_STD_ZVAL(p) MAKE_STD_ZVAL(p)
2229
#define SC_RETURN_STRINGL(k, l) RETURN_STRINGL(k, l, 1)
@@ -78,7 +85,7 @@ static inline zval *sc_zend_hash_index_find(HashTable *ht, ulong h)
7885
#define SC_HASHTABLE_FOREACH_START2(ht, k, klen, ktype, entry)\
7986
zval **tmp = NULL; ulong_t idx;\
8087
for (zend_hash_internal_pointer_reset(ht); \
81-
(ktype = zend_hash_get_current_key_ex(ht, &k, &klen, &idx, 0, NULL)) != HASH_KEY_NON_EXISTENT; \
88+
(ktype = zend_hash_get_current_key_ex(ht, &k, &klen, &idx, 0, NULL)) != HASH_KEY_NON_EXISTANT; \
8289
zend_hash_move_forward(ht)\
8390
) { \
8491
if (zend_hash_get_current_data(ht, (void**)&tmp) == FAILURE) {\
@@ -93,6 +100,8 @@ static inline zval *sc_zend_hash_index_find(HashTable *ht, ulong h)
93100

94101
#else
95102
// PHP5
103+
#define sc_zend_throw_exception zend_throw_exception
104+
96105
#define sc_zend_hash_find zend_hash_str_find
97106
#define sc_zend_hash_index_find zend_hash_index_find
98107
#define SC_MAKE_STD_ZVAL(p) zval _stack_zval_##p; p = &(_stack_zval_##p)

0 commit comments

Comments
 (0)