]> granicus.if.org Git - php/commitdiff
hash keys lengths include the NUL-byte, so we need to copy one byte less.
authorSascha Schumann <sas@php.net>
Mon, 22 Apr 2002 08:18:19 +0000 (08:18 +0000)
committerSascha Schumann <sas@php.net>
Mon, 22 Apr 2002 08:18:19 +0000 (08:18 +0000)
also add missing commas in the INSERT clause.

Noticed by: Yasuo Ohgaki

ext/pgsql/pgsql.c

index fc1d8fc311a259dd7c47e5b3933d25b09c554e15..fe49782b36dba1790ef20ba9952cfc48e062c1a3 100644 (file)
@@ -3908,9 +3908,11 @@ PHPAPI int php_pgsql_insert(PGconn *pg_link, const char *table, zval *var_array,
                                          get_active_function_name(TSRMLS_C));
                        goto cleanup;
                }
-               smart_str_appendl(&querystr, fld, fld_len);
+               smart_str_appendl(&querystr, fld, fld_len - 1);
+               smart_str_appendc(&querystr, ',');
                zend_hash_move_forward_ex(Z_ARRVAL_P(var_array), &pos);
        }
+       querystr.len--;
        smart_str_appends(&querystr, ") VALUES (");
        
        /* make values string */
@@ -4004,7 +4006,7 @@ static inline int build_assignment_string(smart_str *querystr, HashTable *ht, co
                                          get_active_function_name(TSRMLS_C));
                        return -1;
                }
-               smart_str_appendl(querystr, fld, fld_len);
+               smart_str_appendl(querystr, fld, fld_len - 1);
                smart_str_appendc(querystr, '=');
                
                switch(Z_TYPE_PP(val)) {