]> granicus.if.org Git - php/commitdiff
Implement sqlite_escape_string() function.
authorWez Furlong <wez@php.net>
Thu, 17 Apr 2003 02:20:26 +0000 (02:20 +0000)
committerWez Furlong <wez@php.net>
Thu, 17 Apr 2003 02:20:26 +0000 (02:20 +0000)
ext/sqlite/TODO
ext/sqlite/php_sqlite.h
ext/sqlite/sqlite.c

index a299ff032f83a327d74390ef0e4aaac987bd0a59..40f93467d8c8da9336e937a19cb1f2bdd0213642 100644 (file)
@@ -1,9 +1,6 @@
-- Implement safe-mode checks on the filename when opening/creating the
-  database.
-
 - Implement a generic php function handler for use in SQL statements and
   triggers etc.
 
-- Create a package.xml and make a release
+- Make a release
 
 vim:tw=78
index 3966c2d24c3efd0280b9dfa6738a175a151e84e8..206e20c7a2688190e31ed69d9d49be93e66d982e 100644 (file)
@@ -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        |
@@ -12,7 +12,7 @@
   | obtain it through the world-wide-web, please send a note to          |
   | license@php.net so we can mail you a copy immediately.               |
   +----------------------------------------------------------------------+
-  | Author:                                                              |
+  | Author: Wez Furlong <wez@thebrainroom.com>                           |
   +----------------------------------------------------------------------+
 
   $Id$ 
@@ -56,6 +56,8 @@ PHP_FUNCTION(sqlite_libencoding);
 PHP_FUNCTION(sqlite_changes);
 PHP_FUNCTION(sqlite_last_insert_rowid);
 
+PHP_FUNCTION(sqlite_escape_string);
+
 #ifdef ZTS
 #define SQLITE_G(v) TSRMG(sqlite_globals_id, zend_sqlite_globals *, v)
 #else
index 7ff5a20e736461f5dca821b5481ad7685da55d7f..bd4ec3f8554455de91a7cb70c192024322adbfeb 100644 (file)
@@ -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);
+       }
+}
+/* }}} */
+
+