diff options
author | Wez Furlong <wez@php.net> | 2003-04-17 02:20:26 +0000 |
---|---|---|
committer | Wez Furlong <wez@php.net> | 2003-04-17 02:20:26 +0000 |
commit | 5e0b9bb4519fa077c0863b67b607a8b9448e8334 (patch) | |
tree | 5e6cc3dd40cf642acb95643983404102a96b4f5e /ext/sqlite/sqlite.c | |
parent | 2d14d8b52015f7cd972ab123f46777769df8e2ce (diff) | |
download | php-git-5e0b9bb4519fa077c0863b67b607a8b9448e8334.tar.gz |
Implement sqlite_escape_string() function.
Diffstat (limited to 'ext/sqlite/sqlite.c')
-rw-r--r-- | ext/sqlite/sqlite.c | 25 |
1 files changed, 24 insertions, 1 deletions
diff --git a/ext/sqlite/sqlite.c b/ext/sqlite/sqlite.c index 7ff5a20e73..bd4ec3f855 100644 --- a/ext/sqlite/sqlite.c +++ b/ext/sqlite/sqlite.c @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 4 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2002 The PHP Group | + | Copyright (c) 1997-2003 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 2.02 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | @@ -55,6 +55,7 @@ function_entry sqlite_functions[] = { PHP_FE(sqlite_num_fields, NULL) PHP_FE(sqlite_field_name, NULL) PHP_FE(sqlite_seek, NULL) + PHP_FE(sqlite_escape_string, NULL) {NULL, NULL, NULL} }; @@ -395,3 +396,25 @@ PHP_FUNCTION(sqlite_seek) } /* }}} */ +/* {{{ proto string sqlite_escape_string(string item) + Escapes a string for use as a query parameter */ +PHP_FUNCTION(sqlite_escape_string) +{ + char *string; + long stringlen; + char *ret; + + if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &string, &stringlen)) { + return; + } + + ret = sqlite_mprintf("%q", string); + + if (ret) { + RETVAL_STRING(ret, 1); + sqlite_freemem(ret); + } +} +/* }}} */ + + |