diff options
author | Zeev Suraski <zeev@php.net> | 2000-10-11 18:27:21 +0000 |
---|---|---|
committer | Zeev Suraski <zeev@php.net> | 2000-10-11 18:27:21 +0000 |
commit | dea72ba6a4d27e4e972078ddd9774b494ac42039 (patch) | |
tree | 47d215228a50b69a7055e2ffb6b781a19cf45dec /ext/mysql/php_mysql.c | |
parent | b3d949852f3299db2d3b9901b95c1b220f329d36 (diff) | |
download | php-git-dea72ba6a4d27e4e972078ddd9774b494ac42039.tar.gz |
Added mysql_escape_String()
Diffstat (limited to 'ext/mysql/php_mysql.c')
-rw-r--r-- | ext/mysql/php_mysql.c | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/ext/mysql/php_mysql.c b/ext/mysql/php_mysql.c index 35645bf6af..8f06268260 100644 --- a/ext/mysql/php_mysql.c +++ b/ext/mysql/php_mysql.c @@ -120,6 +120,7 @@ function_entry mysql_functions[] = { PHP_FE(mysql_field_len, NULL) PHP_FE(mysql_field_type, NULL) PHP_FE(mysql_field_flags, NULL) + PHP_FE(mysql_escape_string, NULL) /* for downwards compatability */ PHP_FALIAS(mysql, mysql_db_query, NULL) @@ -1073,6 +1074,27 @@ PHP_FUNCTION(mysql_affected_rows) /* }}} */ +/* {{{ proto char mysql_escape_string([char string]) + Escape string for mysql query */ +PHP_FUNCTION(mysql_escape_string) +{ + zval **str; + + if (ZEND_NUM_ARGS()!=1 || zend_get_parameters_ex(1, &str) == FAILURE) { + ZEND_WRONG_PARAM_COUNT(); + } + convert_to_string_ex(str); + /* assume worst case situation, which is 2x of the original string. + * we don't realloc() down to the real size since it'd most probably not + * be worth it + */ + Z_STRVAL_P(return_value) = (char *) emalloc(Z_STRLEN_PP(str)*2+1); + Z_STRLEN_P(return_value) = mysql_escape_string(Z_STRVAL_P(return_value), Z_STRVAL_PP(str), Z_STRLEN_PP(str)); + return_value->type = IS_STRING; +} +/* }}} */ + + /* {{{ proto int mysql_insert_id([int link_identifier]) Get the id generated from the previous INSERT operation */ PHP_FUNCTION(mysql_insert_id) |