zval *result;
PGresult *pgsql_result;
pgsql_result_handle *pg_result;
- long colno=0;
+ unsigned long colno=0;
int pg_numrows, pg_row;
size_t num_fields;
PHP_PGSQL_API int php_pgsql_convert(PGconn *pg_link, const char *table_name, const zval *values, zval *result, ulong opt TSRMLS_DC)
{
HashPosition pos;
+ zstr zfield;
char *field = NULL;
uint field_len = -1;
ulong num_idx = -1;
skip_field = 0;
new_val = NULL;
- if ((key_type = zend_hash_get_current_key_ex(Z_ARRVAL_P(values), &field, &field_len, &num_idx, 0, &pos)) == HASH_KEY_NON_EXISTANT) {
+ if ((key_type = zend_hash_get_current_key_ex(Z_ARRVAL_P(values), &zfield, &field_len, &num_idx, 0, &pos)) == HASH_KEY_NON_EXISTANT) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Failed to get array key type");
err = 1;
}
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Accepts only string key for values");
err = 1;
}
+ field = zfield.s;
if (!err && zend_hash_find(Z_ARRVAL_P(meta), field, field_len, (void **)&def) == FAILURE) {
php_error_docref(NULL TSRMLS_CC, E_NOTICE, "Invalid field name (%s) in values", field);
err = 1;
PHP_PGSQL_API int php_pgsql_insert(PGconn *pg_link, const char *table, zval *var_array, ulong opt, char **sql TSRMLS_DC)
{
zval **val, *converted = NULL;
+ zstr zfld;
char buf[256];
- char *fld;
smart_str querystr = {0};
int key_type, ret = FAILURE;
uint fld_len;
smart_str_appends(&querystr, " (");
zend_hash_internal_pointer_reset_ex(Z_ARRVAL_P(var_array), &pos);
- while ((key_type = zend_hash_get_current_key_ex(Z_ARRVAL_P(var_array), &fld,
+ while ((key_type = zend_hash_get_current_key_ex(Z_ARRVAL_P(var_array), &zfld,
&fld_len, &num_idx, 0, &pos)) != HASH_KEY_NON_EXISTANT) {
if (key_type == HASH_KEY_IS_LONG) {
php_error_docref(NULL TSRMLS_CC, E_NOTICE, "Expects associative array for values to be inserted");
goto cleanup;
}
- smart_str_appendl(&querystr, fld, fld_len - 1);
+ smart_str_appendl(&querystr, zfld.s, fld_len - 1);
smart_str_appendc(&querystr, ',');
zend_hash_move_forward_ex(Z_ARRVAL_P(var_array), &pos);
}
static inline int build_assignment_string(smart_str *querystr, HashTable *ht, const char *pad, int pad_len TSRMLS_DC)
{
HashPosition pos;
+ zstr zfld;
uint fld_len;
int key_type;
ulong num_idx;
- char *fld;
char buf[256];
zval **val;
for (zend_hash_internal_pointer_reset_ex(ht, &pos);
zend_hash_get_current_data_ex(ht, (void **)&val, &pos) == SUCCESS;
zend_hash_move_forward_ex(ht, &pos)) {
- key_type = zend_hash_get_current_key_ex(ht, &fld, &fld_len, &num_idx, 0, &pos);
+ key_type = zend_hash_get_current_key_ex(ht, &zfld, &fld_len, &num_idx, 0, &pos);
if (key_type == HASH_KEY_IS_LONG) {
php_error_docref(NULL TSRMLS_CC, E_NOTICE, "Expects associative array for values to be inserted");
return -1;
}
- smart_str_appendl(querystr, fld, fld_len - 1);
+ smart_str_appendl(querystr, zfld.s, fld_len - 1);
smart_str_appendc(querystr, '=');
-
+
switch(Z_TYPE_PP(val)) {
case IS_STRING:
smart_str_appendl(querystr, Z_STRVAL_PP(val), Z_STRLEN_PP(val));
} else if (hdr.type == FCGI_GET_VALUES) {
unsigned char *p = buf + sizeof(fcgi_header);
HashPosition pos;
- char * str_index;
+ zstr key;
uint str_length;
ulong num_index;
int key_type;
}
zend_hash_internal_pointer_reset_ex(req->env, &pos);
- while ((key_type = zend_hash_get_current_key_ex(req->env, &str_index, &str_length, &num_index, 0, &pos)) != HASH_KEY_NON_EXISTANT) {
+ while ((key_type = zend_hash_get_current_key_ex(req->env, &key, &str_length, &num_index, 0, &pos)) != HASH_KEY_NON_EXISTANT) {
int zlen;
zend_hash_move_forward_ex(req->env, &pos);
if (key_type != HASH_KEY_IS_STRING) {
continue;
}
- if (zend_hash_find(&fcgi_mgmt_vars, str_index, str_length, (void**) &value) != SUCCESS) {
+ if (zend_hash_find(&fcgi_mgmt_vars, key.s, str_length, (void**) &value) != SUCCESS) {
continue;
}
--str_length;
*p++ = (zlen >> 8) & 0xff;
*p++ = zlen & 0xff;
}
- memcpy(p, str_index, str_length);
+ memcpy(p, key.s, str_length);
p += str_length;
memcpy(p, Z_STRVAL_PP(value), zlen);
p += zlen;