1
0
mirror of https://github.com/danog/ext-pq.git synced 2025-01-22 22:01:33 +01:00

make arg to fetchAllCols optional

This commit is contained in:
Michael Wallner 2014-09-15 13:22:20 +02:00
parent dd52670ccf
commit 66a1a0a14a

View File

@ -593,7 +593,14 @@ static STATUS column_nn(php_pqres_object_t *obj, zval *zcol, php_pqres_col_t *co
long index = -1; long index = -1;
char *name = NULL; char *name = NULL;
if (!zcol) {
index = 0;
} else {
switch (Z_TYPE_P(zcol)) { switch (Z_TYPE_P(zcol)) {
case IS_NULL:
index = 0;
break;
case IS_LONG: case IS_LONG:
index = Z_LVAL_P(zcol); index = Z_LVAL_P(zcol);
break; break;
@ -608,6 +615,7 @@ static STATUS column_nn(php_pqres_object_t *obj, zval *zcol, php_pqres_col_t *co
} }
break; break;
} }
}
if (name) { if (name) {
col->name = name; col->name = name;
@ -814,16 +822,16 @@ static PHP_METHOD(pqres, fetchCol) {
} }
} }
ZEND_BEGIN_ARG_INFO_EX(ai_pqres_fetch_all_cols, 0, 0, 1) ZEND_BEGIN_ARG_INFO_EX(ai_pqres_fetch_all_cols, 0, 0, 0)
ZEND_ARG_INFO(0, col) ZEND_ARG_INFO(0, col)
ZEND_END_ARG_INFO(); ZEND_END_ARG_INFO();
static PHP_METHOD(pqres, fetchAllCols) { static PHP_METHOD(pqres, fetchAllCols) {
zend_error_handling zeh; zend_error_handling zeh;
zval *zcol; zval *zcol = NULL;
STATUS rv; STATUS rv;
zend_replace_error_handling(EH_THROW, exce(EX_INVALID_ARGUMENT), &zeh TSRMLS_CC); zend_replace_error_handling(EH_THROW, exce(EX_INVALID_ARGUMENT), &zeh TSRMLS_CC);
rv = zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z", &zcol); rv = zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|z!", &zcol);
zend_restore_error_handling(&zeh TSRMLS_CC); zend_restore_error_handling(&zeh TSRMLS_CC);
if (SUCCESS == rv) { if (SUCCESS == rv) {