diff options
Diffstat (limited to 'ext/dbx/dbx_fbsql.c')
| -rw-r--r-- | ext/dbx/dbx_fbsql.c | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/ext/dbx/dbx_fbsql.c b/ext/dbx/dbx_fbsql.c index 3ab8bbd232..56c3764f0f 100644 --- a/ext/dbx/dbx_fbsql.c +++ b/ext/dbx/dbx_fbsql.c @@ -249,6 +249,28 @@ int dbx_fbsql_error(zval **rv, zval **dbx_handle, INTERNAL_FUNCTION_PARAMETERS) return 1; } +int dbx_fbsql_esc(zval **rv, zval **dbx_handle, zval **string, INTERNAL_FUNCTION_PARAMETERS) +{ + /* returns escaped string */ + /* replace \ with \\ */ + /* ' with '' */ + char * str; + int len; + char * tmpstr; + int tmplen; + + tmpstr = estrdup(Z_STRVAL_PP(string)); + tmplen = Z_STRLEN_PP(string); + /* php_str_to_str uses a smart_str that allocates memory */ + /* this memory must be freed or passed on to rv */ + str = php_str_to_str(tmpstr, tmplen, "'", 1, "''", 2, &len); + efree(tmpstr); + + ZVAL_STRINGL(*rv, str, len, 0); + + return 1; +} + /* * Local variables: * tab-width: 4 |
