[PHP-CVS] cvs: php-src(PHP_5_3) /ext/sqlite3 sqlite3.c /ext/sqlite3/tests sqlite3_enable_exceptions.phpt
scottmacMon Jun 8 02:15:54 2009 UTC Modified files: (Branch: PHP_5_3) /php-src/ext/sqlite3sqlite3.c /php-src/ext/sqlite3/tests sqlite3_enable_exceptions.phpt Log: MFH make SQLite3::enableExceptions() return the previous value. http://cvs.php.net/viewvc.cgi/php-src/ext/sqlite3/sqlite3.c?r1=1.1.2.38r2=1.1.2.39diff_format=u Index: php-src/ext/sqlite3/sqlite3.c diff -u php-src/ext/sqlite3/sqlite3.c:1.1.2.38 php-src/ext/sqlite3/sqlite3.c:1.1.2.39 --- php-src/ext/sqlite3/sqlite3.c:1.1.2.38 Fri May 8 07:58:19 2009 +++ php-src/ext/sqlite3/sqlite3.c Mon Jun 8 02:15:54 2009 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: sqlite3.c,v 1.1.2.38 2009/05/08 07:58:19 tony2001 Exp $ */ +/* $Id: sqlite3.c,v 1.1.2.39 2009/06/08 02:15:54 scottmac Exp $ */ #ifdef HAVE_CONFIG_H #include config.h @@ -1109,8 +1109,8 @@ } /* }}} */ -/* {{{ proto void SQLite3::enableExceptions([bool enableExceptions = false]) - Open a blob as a stream which we can read / write to. */ +/* {{{ proto bool SQLite3::enableExceptions([bool enableExceptions = false]) + Enables an exception error mode. */ PHP_METHOD(sqlite3, enableExceptions) { php_sqlite3_db_object *db_obj; @@ -1123,6 +1123,8 @@ return; } + RETVAL_BOOL(db_obj-exception); + db_obj-exception = enableExceptions; } /* }}} */ http://cvs.php.net/viewvc.cgi/php-src/ext/sqlite3/tests/sqlite3_enable_exceptions.phpt?r1=1.1.2.2r2=1.1.2.3diff_format=u Index: php-src/ext/sqlite3/tests/sqlite3_enable_exceptions.phpt diff -u php-src/ext/sqlite3/tests/sqlite3_enable_exceptions.phpt:1.1.2.2 php-src/ext/sqlite3/tests/sqlite3_enable_exceptions.phpt:1.1.2.3 --- php-src/ext/sqlite3/tests/sqlite3_enable_exceptions.phpt:1.1.2.2Sun May 17 16:51:59 2009 +++ php-src/ext/sqlite3/tests/sqlite3_enable_exceptions.phptMon Jun 8 02:15:54 2009 @@ -23,9 +23,9 @@ echo Done\n; ? --EXPECTF-- -NULL +bool(false) no such table: non_existent_table -NULL +bool(true) Warning: SQLite3::query(): no such table: non_existent_table in %s on line %d -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src(PHP_5_3) /ext/sqlite3 sqlite3.c
tony2001Fri May 8 07:58:19 2009 UTC Modified files: (Branch: PHP_5_3) /php-src/ext/sqlite3sqlite3.c Log: MFH: fix ZTS build http://cvs.php.net/viewvc.cgi/php-src/ext/sqlite3/sqlite3.c?r1=1.1.2.37r2=1.1.2.38diff_format=u Index: php-src/ext/sqlite3/sqlite3.c diff -u php-src/ext/sqlite3/sqlite3.c:1.1.2.37 php-src/ext/sqlite3/sqlite3.c:1.1.2.38 --- php-src/ext/sqlite3/sqlite3.c:1.1.2.37 Thu May 7 22:42:46 2009 +++ php-src/ext/sqlite3/sqlite3.c Fri May 8 07:58:19 2009 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: sqlite3.c,v 1.1.2.37 2009/05/07 22:42:46 felipe Exp $ */ +/* $Id: sqlite3.c,v 1.1.2.38 2009/05/08 07:58:19 tony2001 Exp $ */ #ifdef HAVE_CONFIG_H #include config.h @@ -33,6 +33,7 @@ #include zend_exceptions.h #include zend_interfaces.h +#include SAPI.h ZEND_DECLARE_MODULE_GLOBALS(sqlite3) -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src(PHP_5_3) /ext/sqlite3 sqlite3.c
scottmacThu May 7 16:49:27 2009 UTC Modified files: (Branch: PHP_5_3) /php-src/ext/sqlite3sqlite3.c Log: Print warning when using loadExtension on non cli, cgi and embeded http://cvs.php.net/viewvc.cgi/php-src/ext/sqlite3/sqlite3.c?r1=1.1.2.35r2=1.1.2.36diff_format=u Index: php-src/ext/sqlite3/sqlite3.c diff -u php-src/ext/sqlite3/sqlite3.c:1.1.2.35 php-src/ext/sqlite3/sqlite3.c:1.1.2.36 --- php-src/ext/sqlite3/sqlite3.c:1.1.2.35 Mon Apr 27 18:16:46 2009 +++ php-src/ext/sqlite3/sqlite3.c Thu May 7 16:49:26 2009 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: sqlite3.c,v 1.1.2.35 2009/04/27 18:16:46 scottmac Exp $ */ +/* $Id: sqlite3.c,v 1.1.2.36 2009/05/07 16:49:26 scottmac Exp $ */ #ifdef HAVE_CONFIG_H #include config.h @@ -308,6 +308,15 @@ return; } +#ifdef ZTS + if ((strncmp(sapi_module.name, cgi, 3) != 0) + (strcmp(sapi_module.name, cli) != 0) + (strncmp(sapi_module.name, embed, 5) != 0) + ) { php_sqlite3_error(db_obj, Not supported in multithreaded Web servers); + RETURN_FALSE; + } +#endif + if (!SQLITE3G(extension_dir)) { php_sqlite3_error(db_obj, SQLite Extension are disabled); RETURN_FALSE; -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-CVS] cvs: php-src(PHP_5_3) /ext/sqlite3 sqlite3.c
Hi Scott, scottmac Thu May 7 16:49:27 2009 UTC Modified files: (Branch: PHP_5_3) /php-src/ext/sqlite3 sqlite3.c Log: Print warning when using loadExtension on non cli, cgi and embeded Just did a cvs up of my local PHP_5_3 copy and got a compile failure: /root/compile/php-5.3/ext/sqlite3/sqlite3.c:312: error: `sapi_module' undeclared Adding an #include SAPI.h as suggested by Philip on IRC fixed the issue. Cheers -- M. -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src(PHP_5_3) /ext/sqlite3 sqlite3.c
felipe Thu May 7 22:42:46 2009 UTC Modified files: (Branch: PHP_5_3) /php-src/ext/sqlite3sqlite3.c Log: - Fix build http://cvs.php.net/viewvc.cgi/php-src/ext/sqlite3/sqlite3.c?r1=1.1.2.36r2=1.1.2.37diff_format=u Index: php-src/ext/sqlite3/sqlite3.c diff -u php-src/ext/sqlite3/sqlite3.c:1.1.2.36 php-src/ext/sqlite3/sqlite3.c:1.1.2.37 --- php-src/ext/sqlite3/sqlite3.c:1.1.2.36 Thu May 7 16:49:26 2009 +++ php-src/ext/sqlite3/sqlite3.c Thu May 7 22:42:46 2009 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: sqlite3.c,v 1.1.2.36 2009/05/07 16:49:26 scottmac Exp $ */ +/* $Id: sqlite3.c,v 1.1.2.37 2009/05/07 22:42:46 felipe Exp $ */ #ifdef HAVE_CONFIG_H #include config.h @@ -27,6 +27,7 @@ #include ext/standard/info.h #include php_sqlite3.h #include php_sqlite3_structs.h +#include main/SAPI.h #include sqlite3.h -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src(PHP_5_3) /ext/sqlite3 sqlite3.c
iliaa Wed Feb 18 20:07:40 2009 UTC Modified files: (Branch: PHP_5_3) /php-src/ext/sqlite3sqlite3.c Log: Removed unused var http://cvs.php.net/viewvc.cgi/php-src/ext/sqlite3/sqlite3.c?r1=1.1.2.32r2=1.1.2.33diff_format=u Index: php-src/ext/sqlite3/sqlite3.c diff -u php-src/ext/sqlite3/sqlite3.c:1.1.2.32 php-src/ext/sqlite3/sqlite3.c:1.1.2.33 --- php-src/ext/sqlite3/sqlite3.c:1.1.2.32 Tue Feb 10 00:24:33 2009 +++ php-src/ext/sqlite3/sqlite3.c Wed Feb 18 20:07:40 2009 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: sqlite3.c,v 1.1.2.32 2009/02/10 00:24:33 scottmac Exp $ */ +/* $Id: sqlite3.c,v 1.1.2.33 2009/02/18 20:07:40 iliaa Exp $ */ #ifdef HAVE_CONFIG_H #include config.h @@ -902,7 +902,7 @@ static size_t php_sqlite3_stream_write(php_stream *stream, const char *buf, size_t count TSRMLS_DC) { - php_stream_sqlite3_data *sqlite3_stream = (php_stream_sqlite3_data *) stream-abstract; +/* php_stream_sqlite3_data *sqlite3_stream = (php_stream_sqlite3_data *) stream-abstract; */ return 0; } -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src(PHP_5_3) /ext/sqlite3 sqlite3.c /ext/sqlite3/tests sqlite3_15_open_error.phpt sqlite3_21_security.phpt
scottmacTue Feb 10 00:24:33 2009 UTC Modified files: (Branch: PHP_5_3) /php-src/ext/sqlite3sqlite3.c /php-src/ext/sqlite3/tests sqlite3_15_open_error.phpt sqlite3_21_security.phpt Log: The constructor should also throw exceptions, make this semi useful now. http://cvs.php.net/viewvc.cgi/php-src/ext/sqlite3/sqlite3.c?r1=1.1.2.31r2=1.1.2.32diff_format=u Index: php-src/ext/sqlite3/sqlite3.c diff -u php-src/ext/sqlite3/sqlite3.c:1.1.2.31 php-src/ext/sqlite3/sqlite3.c:1.1.2.32 --- php-src/ext/sqlite3/sqlite3.c:1.1.2.31 Wed Jan 28 23:58:09 2009 +++ php-src/ext/sqlite3/sqlite3.c Tue Feb 10 00:24:33 2009 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: sqlite3.c,v 1.1.2.31 2009/01/28 23:58:09 scottmac Exp $ */ +/* $Id: sqlite3.c,v 1.1.2.32 2009/02/10 00:24:33 scottmac Exp $ */ #ifdef HAVE_CONFIG_H #include config.h @@ -72,29 +72,38 @@ char *filename, *encryption_key, *fullpath; int filename_len, encryption_key_len = 0; long flags = SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE; + zend_error_handling error_handling; + db_obj = (php_sqlite3_db_object *)zend_object_store_get_object(object TSRMLS_CC); + zend_replace_error_handling(EH_THROW, NULL, error_handling TSRMLS_CC); if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, s|ls, filename, filename_len, flags, encryption_key, encryption_key_len)) { + zend_restore_error_handling(error_handling TSRMLS_CC); return; } + zend_restore_error_handling(error_handling TSRMLS_CC); + if (db_obj-initialised) { - php_error_docref(NULL TSRMLS_CC, E_NOTICE, Already initialised DB Object); + zend_throw_exception(zend_exception_get_default(TSRMLS_C), Already initialised DB Object, 0 TSRMLS_CC); } if (strncmp(filename, :memory:, 8) != 0) { if (!(fullpath = expand_filepath(filename, NULL TSRMLS_CC))) { - RETURN_FALSE; + zend_throw_exception(zend_exception_get_default(TSRMLS_C), Unable to expand filepath, 0 TSRMLS_CC); + return; } if (PG(safe_mode) (!php_checkuid(fullpath, NULL, CHECKUID_CHECK_FILE_AND_DIR))) { + zend_throw_exception_ex(zend_exception_get_default(TSRMLS_C), 0 TSRMLS_CC, safe_mode prohibits opening %s, fullpath); efree(fullpath); - RETURN_FALSE; + return; } if (php_check_open_basedir(fullpath TSRMLS_CC)) { + zend_throw_exception_ex(zend_exception_get_default(TSRMLS_C), 0 TSRMLS_CC, open_basedir prohibits opening %s, fullpath); efree(fullpath); - RETURN_FALSE; + return; } } else { fullpath = estrdup(filename); @@ -105,7 +114,7 @@ #else if (sqlite3_open(fullpath, (db_obj-db)) != SQLITE_OK) { #endif - php_error_docref(NULL TSRMLS_CC, E_NOTICE, Unable to open database: %s, sqlite3_errmsg(db_obj-db)); + zend_throw_exception_ex(zend_exception_get_default(TSRMLS_C), 0 TSRMLS_CC, Unable to open database: %s, sqlite3_errmsg(db_obj-db)); if (fullpath) { efree(fullpath); } @@ -117,6 +126,7 @@ #if SQLITE_HAS_CODEC if (encryption_key_len 0) { if (sqlite3_key(db_obj-db, encryption_key, encryption_key_len) != SQLITE_OK) { + zend_throw_exception_ex(zend_exception_get_default(TSRMLS_C), 0 TSRMLS_CC, Unable to open database: %s, sqlite3_errmsg(db_obj-db)); return; } } @@ -129,7 +139,6 @@ if (fullpath) { efree(fullpath); } - RETURN_TRUE; } /* }}} */ http://cvs.php.net/viewvc.cgi/php-src/ext/sqlite3/tests/sqlite3_15_open_error.phpt?r1=1.1.2.2r2=1.1.2.3diff_format=u Index: php-src/ext/sqlite3/tests/sqlite3_15_open_error.phpt diff -u php-src/ext/sqlite3/tests/sqlite3_15_open_error.phpt:1.1.2.2 php-src/ext/sqlite3/tests/sqlite3_15_open_error.phpt:1.1.2.3 --- php-src/ext/sqlite3/tests/sqlite3_15_open_error.phpt:1.1.2.2Sun Jul 27 00:05:36 2008 +++ php-src/ext/sqlite3/tests/sqlite3_15_open_error.phptTue Feb 10 00:24:33 2009 @@ -7,14 +7,17 @@ $unreadable = dirname(__FILE__) . '/unreadable.db'; touch($unreadable); chmod($unreadable, 0200); -$db = new SQLite3($unreadable); - -var_dump($db); +try { + $db = new SQLite3($unreadable); +} catch (Exception $e) { + echo $e . \n; +} echo Done\n; unlink($unreadable); ? --EXPECTF-- -Notice: SQLite3::__construct(): Unable to open database: unable to open database file in
[PHP-CVS] cvs: php-src(PHP_5_3) /ext/sqlite3 sqlite3.c
scottmacWed Jan 28 23:58:10 2009 UTC Modified files: (Branch: PHP_5_3) /php-src/ext/sqlite3sqlite3.c Log: Fix build on Windows http://cvs.php.net/viewvc.cgi/php-src/ext/sqlite3/sqlite3.c?r1=1.1.2.30r2=1.1.2.31diff_format=u Index: php-src/ext/sqlite3/sqlite3.c diff -u php-src/ext/sqlite3/sqlite3.c:1.1.2.30 php-src/ext/sqlite3/sqlite3.c:1.1.2.31 --- php-src/ext/sqlite3/sqlite3.c:1.1.2.30 Sat Jan 24 13:08:04 2009 +++ php-src/ext/sqlite3/sqlite3.c Wed Jan 28 23:58:09 2009 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: sqlite3.c,v 1.1.2.30 2009/01/24 13:08:04 tony2001 Exp $ */ +/* $Id: sqlite3.c,v 1.1.2.31 2009/01/28 23:58:09 scottmac Exp $ */ #ifdef HAVE_CONFIG_H #include config.h @@ -1011,7 +1011,7 @@ return -1; } -PHPAPI php_stream_ops php_stream_sqlite3_ops = { +static php_stream_ops php_stream_sqlite3_ops = { php_sqlite3_stream_write, php_sqlite3_stream_read, php_sqlite3_stream_close, -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src(PHP_5_3) /ext/sqlite3 sqlite3.c /ext/sqlite3/tests sqlite3_30_blobopen.phpt
scottmacSat Jan 24 12:17:48 2009 UTC Added files: (Branch: PHP_5_3) /php-src/ext/sqlite3/tests sqlite3_30_blobopen.phpt Modified files: /php-src/ext/sqlite3sqlite3.c Log: MFH Add blobOpen method for reading binary blobs via streams. http://cvs.php.net/viewvc.cgi/php-src/ext/sqlite3/sqlite3.c?r1=1.1.2.28r2=1.1.2.29diff_format=u Index: php-src/ext/sqlite3/sqlite3.c diff -u php-src/ext/sqlite3/sqlite3.c:1.1.2.28 php-src/ext/sqlite3/sqlite3.c:1.1.2.29 --- php-src/ext/sqlite3/sqlite3.c:1.1.2.28 Tue Jan 20 09:57:34 2009 +++ php-src/ext/sqlite3/sqlite3.c Sat Jan 24 12:17:47 2009 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: sqlite3.c,v 1.1.2.28 2009/01/20 09:57:34 scottmac Exp $ */ +/* $Id: sqlite3.c,v 1.1.2.29 2009/01/24 12:17:47 scottmac Exp $ */ #ifdef HAVE_CONFIG_H #include config.h @@ -769,7 +769,7 @@ } /* }}} */ -/* {{{ proto bool SQLite3::createFunction(string name, mixed callback [, int argcount])) +/* {{{ proto bool SQLite3::createFunction(string name, mixed callback [, int argcount]) Allows registration of a PHP function as a SQLite UDF that can be called within SQL statements. */ PHP_METHOD(sqlite3, createFunction) { @@ -821,7 +821,7 @@ } /* }}} */ -/* {{{ proto bool SQLite3::createAggregate(string name, mixed step, mixed final [, int argcount])) +/* {{{ proto bool SQLite3::createAggregate(string name, mixed step, mixed final [, int argcount]) Allows registration of a PHP function for use as an aggregate. */ PHP_METHOD(sqlite3, createAggregate) { @@ -885,6 +885,184 @@ } /* }}} */ +typedef struct { + sqlite3_blob *blob; + size_t position; + size_t size; +} php_stream_sqlite3_data; + +static size_t php_sqlite3_stream_write(php_stream *stream, const char *buf, size_t count TSRMLS_DC) +{ + php_stream_sqlite3_data *sqlite3_stream = (php_stream_sqlite3_data *) stream-abstract; + + return 0; +} + +static size_t php_sqlite3_stream_read(php_stream *stream, char *buf, size_t count TSRMLS_DC) +{ + php_stream_sqlite3_data *sqlite3_stream = (php_stream_sqlite3_data *) stream-abstract; + + if (sqlite3_stream-position + count = sqlite3_stream-size) { + count = sqlite3_stream-size - sqlite3_stream-position; + stream-eof = 1; + } + if (count) { + if (sqlite3_blob_read(sqlite3_stream-blob, buf, count, sqlite3_stream-position) != SQLITE_OK) { + return 0; + } + sqlite3_stream-position += count; + } + return count; +} + +static int php_sqlite3_stream_close(php_stream *stream, int close_handle TSRMLS_DC) +{ + php_stream_sqlite3_data *sqlite3_stream = (php_stream_sqlite3_data *) stream-abstract; + + if (sqlite3_blob_close(sqlite3_stream-blob) != SQLITE_OK) { + /* Error occured, but it still closed */ + } + + efree(sqlite3_stream); + + return 0; +} + +static int php_sqlite3_stream_flush(php_stream *stream TSRMLS_DC) +{ + /* do nothing */ + return 0; +} + +/* {{{ */ +static int php_sqlite3_stream_seek(php_stream *stream, off_t offset, int whence, off_t *newoffs TSRMLS_DC) +{ + php_stream_sqlite3_data *sqlite3_stream = (php_stream_sqlite3_data *) stream-abstract; + + switch(whence) { + case SEEK_CUR: + if (offset 0) { + if (sqlite3_stream-position (size_t)(-offset)) { + sqlite3_stream-position = 0; + *newoffs = -1; + return -1; + } else { + sqlite3_stream-position = sqlite3_stream-position + offset; + *newoffs = sqlite3_stream-position; + stream-eof = 0; + return 0; + } + } else { + if (sqlite3_stream-position + (size_t)(offset) sqlite3_stream-size) { + sqlite3_stream-position = sqlite3_stream-size; + *newoffs = -1; + return -1; + } else { + sqlite3_stream-position = sqlite3_stream-position + offset; + *newoffs = sqlite3_stream-position; + stream-eof = 0; + return 0; + } + } + case SEEK_SET: + if (sqlite3_stream-size (size_t)(offset)) { +
[PHP-CVS] cvs: php-src(PHP_5_3) /ext/sqlite3 sqlite3.c
tony2001Sat Jan 24 13:08:05 2009 UTC Modified files: (Branch: PHP_5_3) /php-src/ext/sqlite3sqlite3.c Log: fix build http://cvs.php.net/viewvc.cgi/php-src/ext/sqlite3/sqlite3.c?r1=1.1.2.29r2=1.1.2.30diff_format=u Index: php-src/ext/sqlite3/sqlite3.c diff -u php-src/ext/sqlite3/sqlite3.c:1.1.2.29 php-src/ext/sqlite3/sqlite3.c:1.1.2.30 --- php-src/ext/sqlite3/sqlite3.c:1.1.2.29 Sat Jan 24 12:17:47 2009 +++ php-src/ext/sqlite3/sqlite3.c Sat Jan 24 13:08:04 2009 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: sqlite3.c,v 1.1.2.29 2009/01/24 12:17:47 scottmac Exp $ */ +/* $Id: sqlite3.c,v 1.1.2.30 2009/01/24 13:08:04 tony2001 Exp $ */ #ifdef HAVE_CONFIG_H #include config.h @@ -1053,7 +1053,7 @@ sqlite3_stream-position = 0; sqlite3_stream-size = sqlite3_blob_bytes(blob); - stream = php_stream_alloc_rel(php_stream_sqlite3_ops, sqlite3_stream, 0, rb); + stream = php_stream_alloc(php_stream_sqlite3_ops, sqlite3_stream, 0, rb); if (stream) { php_stream_to_zval(stream, return_value); -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src(PHP_5_3) /ext/sqlite3 sqlite3.c /ext/sqlite3/tests bug47159.phpt
scottmacTue Jan 20 09:57:34 2009 UTC Added files: (Branch: PHP_5_3) /php-src/ext/sqlite3/tests bug47159.phpt Modified files: /php-src/ext/sqlite3sqlite3.c Log: MFH Fix bug #47159 - Any SQLite3 statement prepared should be added to the freelist http://cvs.php.net/viewvc.cgi/php-src/ext/sqlite3/sqlite3.c?r1=1.1.2.27r2=1.1.2.28diff_format=u Index: php-src/ext/sqlite3/sqlite3.c diff -u php-src/ext/sqlite3/sqlite3.c:1.1.2.27 php-src/ext/sqlite3/sqlite3.c:1.1.2.28 --- php-src/ext/sqlite3/sqlite3.c:1.1.2.27 Tue Jan 20 00:24:13 2009 +++ php-src/ext/sqlite3/sqlite3.c Tue Jan 20 09:57:34 2009 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: sqlite3.c,v 1.1.2.27 2009/01/20 00:24:13 scottmac Exp $ */ +/* $Id: sqlite3.c,v 1.1.2.28 2009/01/20 09:57:34 scottmac Exp $ */ #ifdef HAVE_CONFIG_H #include config.h @@ -370,6 +370,8 @@ zval *object = getThis(); char *sql; int sql_len, errcode; + php_sqlite3_free_list *free_item; + db_obj = (php_sqlite3_db_object *)zend_object_store_get_object(object TSRMLS_CC); SQLITE3_CHECK_INITIALIZED(db_obj-initialised, SQLite3) @@ -388,14 +390,21 @@ stmt_obj-db_obj_zval = getThis(); Z_ADDREF_P(object); - + errcode = sqlite3_prepare_v2(db_obj-db, sql, sql_len, (stmt_obj-stmt), NULL); if (errcode != SQLITE_OK) { php_error_docref(NULL TSRMLS_CC, E_WARNING, Unable to prepare statement: %d, %s, errcode, sqlite3_errmsg(db_obj-db)); zval_dtor(return_value); RETURN_FALSE; } + stmt_obj-initialised = 1; + + free_item = emalloc(sizeof(php_sqlite3_free_list)); + free_item-stmt_obj = stmt_obj; + free_item-stmt_obj_zval = return_value; + + zend_llist_add_element((db_obj-free_list), free_item); } /* }}} */ @@ -1067,7 +1076,6 @@ zval *object = getThis(); int return_code = 0; struct php_sqlite3_bound_param *param; - php_sqlite3_free_list *free_item; stmt_obj = (php_sqlite3_stmt *)zend_object_store_get_object(object TSRMLS_CC); @@ -1142,11 +1150,6 @@ } return_code = sqlite3_step(stmt_obj-stmt); - free_item = emalloc(sizeof(php_sqlite3_free_list)); - free_item-stmt_obj = stmt_obj; - free_item-stmt_obj_zval = getThis(); - - zend_llist_add_element((stmt_obj-db_obj-free_list), free_item); switch (return_code) { case SQLITE_ROW: /* Valid Row */ @@ -1189,6 +1192,7 @@ char *sql; int sql_len, errcode; zend_error_handling error_handling; + php_sqlite3_free_list *free_item; stmt_obj = (php_sqlite3_stmt *)zend_object_store_get_object(object TSRMLS_CC); zend_replace_error_handling(EH_THROW, NULL, error_handling TSRMLS_CC); @@ -1220,6 +1224,12 @@ RETURN_FALSE; } stmt_obj-initialised = 1; + + free_item = emalloc(sizeof(php_sqlite3_free_list)); + free_item-stmt_obj = stmt_obj; + free_item-stmt_obj_zval = getThis(); + + zend_llist_add_element((db_obj-free_list), free_item); } /* }}} */ http://cvs.php.net/viewvc.cgi/php-src/ext/sqlite3/tests/bug47159.phpt?view=markuprev=1.1 Index: php-src/ext/sqlite3/tests/bug47159.phpt +++ php-src/ext/sqlite3/tests/bug47159.phpt --TEST-- Bug #45798 (sqlite3 doesn't track unexecuted statements) --SKIPIF-- ?php require_once(dirname(__FILE__) . '/skipif.inc'); ? --FILE-- ?php require_once(dirname(__FILE__) . '/new_db.inc'); class MyStmt extends SQLite3Stmt { } $stmt = $db-prepare(SELECT 1); var_dump($stmt-close()); var_dump($db-close()); print done; ? --EXPECT-- bool(true) bool(true) done -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src(PHP_5_3) /ext/sqlite3 sqlite3.c
scottmacTue Jan 20 00:24:14 2009 UTC Modified files: (Branch: PHP_5_3) /php-src/ext/sqlite3sqlite3.c Log: MFH Fix bug #47145 - As soon as sqlite3_step is called on a statement it always must be finalised. http://cvs.php.net/viewvc.cgi/php-src/ext/sqlite3/sqlite3.c?r1=1.1.2.26r2=1.1.2.27diff_format=u Index: php-src/ext/sqlite3/sqlite3.c diff -u php-src/ext/sqlite3/sqlite3.c:1.1.2.26 php-src/ext/sqlite3/sqlite3.c:1.1.2.27 --- php-src/ext/sqlite3/sqlite3.c:1.1.2.26 Mon Jan 19 22:43:58 2009 +++ php-src/ext/sqlite3/sqlite3.c Tue Jan 20 00:24:13 2009 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: sqlite3.c,v 1.1.2.26 2009/01/19 22:43:58 scottmac Exp $ */ +/* $Id: sqlite3.c,v 1.1.2.27 2009/01/20 00:24:13 scottmac Exp $ */ #ifdef HAVE_CONFIG_H #include config.h @@ -1067,6 +1067,8 @@ zval *object = getThis(); int return_code = 0; struct php_sqlite3_bound_param *param; + php_sqlite3_free_list *free_item; + stmt_obj = (php_sqlite3_stmt *)zend_object_store_get_object(object TSRMLS_CC); if (zend_parse_parameters_none() == FAILURE) { @@ -1140,13 +1142,16 @@ } return_code = sqlite3_step(stmt_obj-stmt); + free_item = emalloc(sizeof(php_sqlite3_free_list)); + free_item-stmt_obj = stmt_obj; + free_item-stmt_obj_zval = getThis(); + + zend_llist_add_element((stmt_obj-db_obj-free_list), free_item); switch (return_code) { case SQLITE_ROW: /* Valid Row */ case SQLITE_DONE: /* Valid but no results */ { - php_sqlite3_free_list *free_item; - sqlite3_reset(stmt_obj-stmt); object_init_ex(return_value, php_sqlite3_result_entry); result = (php_sqlite3_result *)zend_object_store_get_object(return_value TSRMLS_CC); @@ -1158,12 +1163,6 @@ result-stmt_obj = stmt_obj; result-stmt_obj_zval = getThis(); - free_item = emalloc(sizeof(php_sqlite3_free_list)); - free_item-stmt_obj = stmt_obj; - free_item-stmt_obj_zval = getThis(); - - zend_llist_add_element((stmt_obj-db_obj-free_list), free_item); - break; } case SQLITE_ERROR: -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src(PHP_5_3) /ext/sqlite3 sqlite3.c
iliaa Sun Jan 4 16:31:12 2009 UTC Modified files: (Branch: PHP_5_3) /php-src/ext/sqlite3sqlite3.c Log: Added missing initialization http://cvs.php.net/viewvc.cgi/php-src/ext/sqlite3/sqlite3.c?r1=1.1.2.24r2=1.1.2.25diff_format=u Index: php-src/ext/sqlite3/sqlite3.c diff -u php-src/ext/sqlite3/sqlite3.c:1.1.2.24 php-src/ext/sqlite3/sqlite3.c:1.1.2.25 --- php-src/ext/sqlite3/sqlite3.c:1.1.2.24 Sat Jan 3 22:08:38 2009 +++ php-src/ext/sqlite3/sqlite3.c Sun Jan 4 16:31:12 2009 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: sqlite3.c,v 1.1.2.24 2009/01/03 22:08:38 felipe Exp $ */ +/* $Id: sqlite3.c,v 1.1.2.25 2009/01/04 16:31:12 iliaa Exp $ */ #ifdef HAVE_CONFIG_H #include config.h @@ -70,7 +70,7 @@ php_sqlite3_db_object *db_obj; zval *object = getThis(); char *filename, *encryption_key, *fullpath; - int filename_len, encryption_key_len; + int filename_len, encryption_key_len = 0; long flags = SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE; db_obj = (php_sqlite3_db_object *)zend_object_store_get_object(object TSRMLS_CC); -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src(PHP_5_3) /ext/sqlite3 sqlite3.c
felipe Sat Jan 3 22:08:39 2009 UTC Modified files: (Branch: PHP_5_3) /php-src/ext/sqlite3sqlite3.c Log: MFH: - Removed unnecessary repeated arginfos - Changed sqlite3stmt and sqlite3result to ZEND_ACC_PRIVATE to avoid reflection instantiation http://cvs.php.net/viewvc.cgi/php-src/ext/sqlite3/sqlite3.c?r1=1.1.2.23r2=1.1.2.24diff_format=u Index: php-src/ext/sqlite3/sqlite3.c diff -u php-src/ext/sqlite3/sqlite3.c:1.1.2.23 php-src/ext/sqlite3/sqlite3.c:1.1.2.24 --- php-src/ext/sqlite3/sqlite3.c:1.1.2.23 Wed Dec 31 11:15:44 2008 +++ php-src/ext/sqlite3/sqlite3.c Sat Jan 3 22:08:38 2009 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: sqlite3.c,v 1.1.2.23 2008/12/31 11:15:44 sebastian Exp $ */ +/* $Id: sqlite3.c,v 1.1.2.24 2009/01/03 22:08:38 felipe Exp $ */ #ifdef HAVE_CONFIG_H #include config.h @@ -1411,40 +1411,14 @@ ZEND_ARG_INFO(0, encryption_key) ZEND_END_ARG_INFO() -ZEND_BEGIN_ARG_INFO(arginfo_sqlite3_close, 0) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO(arginfo_sqlite3_exec, 0) - ZEND_ARG_INFO(0, query) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO(arginfo_sqlite3_version, 0) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO(arginfo_sqlite3_lastinsertrowid, 0) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO(arginfo_sqlite3_lasterrorcode, 0) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO(arginfo_sqlite3_lasterrormsg, 0) -ZEND_END_ARG_INFO() - ZEND_BEGIN_ARG_INFO(arginfo_sqlite3_loadextension, 0) ZEND_ARG_INFO(0, shared_library) ZEND_END_ARG_INFO() -ZEND_BEGIN_ARG_INFO(arginfo_sqlite3_changes, 0) -ZEND_END_ARG_INFO() - ZEND_BEGIN_ARG_INFO_EX(arginfo_sqlite3_escapestring, 0, 0, 1) ZEND_ARG_INFO(0, value) ZEND_END_ARG_INFO() -ZEND_BEGIN_ARG_INFO_EX(arginfo_sqlite3_prepare, 0, 0, 1) - ZEND_ARG_INFO(0, query) -ZEND_END_ARG_INFO() - ZEND_BEGIN_ARG_INFO_EX(arginfo_sqlite3_query, 0, 0, 1) ZEND_ARG_INFO(0, query) ZEND_END_ARG_INFO() @@ -1467,21 +1441,6 @@ ZEND_ARG_INFO(0, argument_count) ZEND_END_ARG_INFO() -ZEND_BEGIN_ARG_INFO(arginfo_sqlite3stmt_paramcount, 0) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO(arginfo_sqlite3stmt_close, 0) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO(arginfo_sqlite3stmt_reset, 0) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO(arginfo_sqlite3stmt_clear, 0) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO(arginfo_sqlite3stmt_execute, 0) -ZEND_END_ARG_INFO() - ZEND_BEGIN_ARG_INFO_EX(arginfo_sqlite3stmt_bindparam, 0, 0, 2) ZEND_ARG_INFO(0, param_number) ZEND_ARG_INFO(1, param) @@ -1498,9 +1457,6 @@ ZEND_ARG_INFO(0, sqlite3) ZEND_END_ARG_INFO() -ZEND_BEGIN_ARG_INFO(arginfo_sqlite3result_numcolumns, 0) -ZEND_END_ARG_INFO() - ZEND_BEGIN_ARG_INFO_EX(arginfo_sqlite3result_columnname, 0, 0, 1) ZEND_ARG_INFO(0, column_number) ZEND_END_ARG_INFO() @@ -1513,29 +1469,23 @@ ZEND_ARG_INFO(0, mode) ZEND_END_ARG_INFO() -ZEND_BEGIN_ARG_INFO(arginfo_sqlite3result_reset, 0) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO(arginfo_sqlite3result_finalize, 0) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO(arginfo_sqlite3result_construct, 0) +ZEND_BEGIN_ARG_INFO(arginfo_sqlite3_void, 0) ZEND_END_ARG_INFO() /* }}} */ /* {{{ php_sqlite3_class_methods */ static zend_function_entry php_sqlite3_class_methods[] = { PHP_ME(sqlite3, open, arginfo_sqlite3_open, ZEND_ACC_PUBLIC) - PHP_ME(sqlite3, close, arginfo_sqlite3_close, ZEND_ACC_PUBLIC) - PHP_ME(sqlite3, exec, arginfo_sqlite3_exec, ZEND_ACC_PUBLIC) - PHP_ME(sqlite3, version, arginfo_sqlite3_version, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC) - PHP_ME(sqlite3, lastInsertRowID, arginfo_sqlite3_lastinsertrowid, ZEND_ACC_PUBLIC) - PHP_ME(sqlite3, lastErrorCode, arginfo_sqlite3_lasterrorcode, ZEND_ACC_PUBLIC) - PHP_ME(sqlite3, lastErrorMsg, arginfo_sqlite3_lasterrormsg, ZEND_ACC_PUBLIC) + PHP_ME(sqlite3, close, arginfo_sqlite3_void, ZEND_ACC_PUBLIC) + PHP_ME(sqlite3, exec, arginfo_sqlite3_query, ZEND_ACC_PUBLIC) + PHP_ME(sqlite3, version, arginfo_sqlite3_void, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC) + PHP_ME(sqlite3, lastInsertRowID,arginfo_sqlite3_void, ZEND_ACC_PUBLIC) + PHP_ME(sqlite3, lastErrorCode, arginfo_sqlite3_void, ZEND_ACC_PUBLIC) + PHP_ME(sqlite3, lastErrorMsg, arginfo_sqlite3_void, ZEND_ACC_PUBLIC) PHP_ME(sqlite3, loadExtension, arginfo_sqlite3_loadextension, ZEND_ACC_PUBLIC) - PHP_ME(sqlite3, changes, arginfo_sqlite3_changes, ZEND_ACC_PUBLIC) + PHP_ME(sqlite3,
[PHP-CVS] cvs: php-src(PHP_5_3) /ext/sqlite3 sqlite3.c /ext/sqlite3/tests sqlite3_29_createfunction.phpt
felipe Fri Nov 28 15:37:02 2008 UTC Added files: (Branch: PHP_5_3) /php-src/ext/sqlite3/tests sqlite3_29_createfunction.phpt Modified files: /php-src/ext/sqlite3sqlite3.c Log: - MFH: Fixed memory leaks in createFunction and createAggregate methods http://cvs.php.net/viewvc.cgi/php-src/ext/sqlite3/sqlite3.c?r1=1.1.2.20r2=1.1.2.21diff_format=u Index: php-src/ext/sqlite3/sqlite3.c diff -u php-src/ext/sqlite3/sqlite3.c:1.1.2.20 php-src/ext/sqlite3/sqlite3.c:1.1.2.21 --- php-src/ext/sqlite3/sqlite3.c:1.1.2.20 Thu Nov 27 19:01:23 2008 +++ php-src/ext/sqlite3/sqlite3.c Fri Nov 28 15:37:02 2008 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: sqlite3.c,v 1.1.2.20 2008/11/27 19:01:23 dmitry Exp $ */ +/* $Id: sqlite3.c,v 1.1.2.21 2008/11/28 15:37:02 felipe Exp $ */ #ifdef HAVE_CONFIG_H #include config.h @@ -791,6 +791,7 @@ MAKE_STD_ZVAL(func-func); *(func-func) = *callback_func; zval_copy_ctor(func-func); + INIT_PZVAL(func-func); func-argc = sql_func_num_args; func-next = db_obj-funcs; @@ -849,10 +850,12 @@ MAKE_STD_ZVAL(func-step); *(func-step) = *step_callback; zval_copy_ctor(func-step); + INIT_PZVAL(func-step); MAKE_STD_ZVAL(func-fini); *(func-fini) = *fini_callback; zval_copy_ctor(func-fini); + INIT_PZVAL(func-fini); func-argc = sql_func_num_args; func-next = db_obj-funcs; http://cvs.php.net/viewvc.cgi/php-src/ext/sqlite3/tests/sqlite3_29_createfunction.phpt?view=markuprev=1.1 Index: php-src/ext/sqlite3/tests/sqlite3_29_createfunction.phpt +++ php-src/ext/sqlite3/tests/sqlite3_29_createfunction.phpt --TEST-- SQLite3::createFunction - Basic test --SKIPIF-- ?php require_once(dirname(__FILE__) . '/skipif.inc'); ? --FILE-- ?php require_once(dirname(__FILE__) . '/new_db.inc'); $func = 'strtoupper'; var_dump($db-createfunction($func, $func)); var_dump($db-querySingle('SELECT strtoupper(test)')); $func2 = 'strtolower'; var_dump($db-createfunction($func2, $func2)); var_dump($db-querySingle('SELECT strtolower(TEST)')); var_dump($db-createfunction($func, $func2)); var_dump($db-querySingle('SELECT strtoupper(tEst)')); ? --EXPECTF-- bool(true) %string|unicode%(4) TEST bool(true) %string|unicode%(4) test bool(true) %string|unicode%(4) test -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src(PHP_5_3) /ext/sqlite3 sqlite3.c
pajoye Thu Nov 20 10:22:55 2008 UTC Modified files: (Branch: PHP_5_3) /php-src/ext/sqlite3sqlite3.c Log: - MFH: declarations must be.. 1st http://cvs.php.net/viewvc.cgi/php-src/ext/sqlite3/sqlite3.c?r1=1.1.2.18r2=1.1.2.19diff_format=u Index: php-src/ext/sqlite3/sqlite3.c diff -u php-src/ext/sqlite3/sqlite3.c:1.1.2.18 php-src/ext/sqlite3/sqlite3.c:1.1.2.19 --- php-src/ext/sqlite3/sqlite3.c:1.1.2.18 Wed Nov 19 02:00:53 2008 +++ php-src/ext/sqlite3/sqlite3.c Thu Nov 20 10:22:55 2008 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: sqlite3.c,v 1.1.2.18 2008/11/19 02:00:53 colder Exp $ */ +/* $Id: sqlite3.c,v 1.1.2.19 2008/11/20 10:22:55 pajoye Exp $ */ #ifdef HAVE_CONFIG_H #include config.h @@ -1380,9 +1380,11 @@ { php_sqlite3_result *result_obj; zval *object = getThis(); - result_obj = (php_sqlite3_result *)zend_object_store_get_object(object TSRMLS_CC); zend_error_handling error_handling; + result_obj = (php_sqlite3_result *)zend_object_store_get_object(object TSRMLS_CC); + + zend_replace_error_handling(EH_THROW, NULL, error_handling TSRMLS_CC); php_error_docref(NULL TSRMLS_CC, E_WARNING, SQLite3Result cannot be directly instantiated); -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src(PHP_5_3) /ext/sqlite3 sqlite3.c
pajoye Tue Nov 18 14:27:09 2008 UTC Modified files: (Branch: PHP_5_3) /php-src/ext/sqlite3sqlite3.c Log: - MFH: declaration has to be first... http://cvs.php.net/viewvc.cgi/php-src/ext/sqlite3/sqlite3.c?r1=1.1.2.16r2=1.1.2.17diff_format=u Index: php-src/ext/sqlite3/sqlite3.c diff -u php-src/ext/sqlite3/sqlite3.c:1.1.2.16 php-src/ext/sqlite3/sqlite3.c:1.1.2.17 --- php-src/ext/sqlite3/sqlite3.c:1.1.2.16 Mon Nov 17 19:34:03 2008 +++ php-src/ext/sqlite3/sqlite3.c Tue Nov 18 14:27:09 2008 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: sqlite3.c,v 1.1.2.16 2008/11/17 19:34:03 scottmac Exp $ */ +/* $Id: sqlite3.c,v 1.1.2.17 2008/11/18 14:27:09 pajoye Exp $ */ #ifdef HAVE_CONFIG_H #include config.h @@ -1177,10 +1177,10 @@ php_sqlite3_db_object *db_obj; zval *object = getThis(); zval *db_zval; - stmt_obj = (php_sqlite3_stmt *)zend_object_store_get_object(object TSRMLS_CC); char *sql; int sql_len, errcode; + stmt_obj = (php_sqlite3_stmt *)zend_object_store_get_object(object TSRMLS_CC); zend_replace_error_handling(EH_THROW, NULL, NULL TSRMLS_CC); if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, Os, db_zval, php_sqlite3_sc_entry, sql, sql_len) == FAILURE) { -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src(PHP_5_3) /ext/sqlite3 sqlite3.c
scottmacMon Nov 17 19:34:03 2008 UTC Modified files: (Branch: PHP_5_3) /php-src/ext/sqlite3sqlite3.c Log: MFH Fix #46033 - Segfault when instantiating SQLite3stmt and SQLite3Result directly. http://cvs.php.net/viewvc.cgi/php-src/ext/sqlite3/sqlite3.c?r1=1.1.2.15r2=1.1.2.16diff_format=u Index: php-src/ext/sqlite3/sqlite3.c diff -u php-src/ext/sqlite3/sqlite3.c:1.1.2.15 php-src/ext/sqlite3/sqlite3.c:1.1.2.16 --- php-src/ext/sqlite3/sqlite3.c:1.1.2.15 Mon Nov 17 11:27:59 2008 +++ php-src/ext/sqlite3/sqlite3.c Mon Nov 17 19:34:03 2008 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: sqlite3.c,v 1.1.2.15 2008/11/17 11:27:59 felipe Exp $ */ +/* $Id: sqlite3.c,v 1.1.2.16 2008/11/17 19:34:03 scottmac Exp $ */ #ifdef HAVE_CONFIG_H #include config.h @@ -512,7 +512,7 @@ } /* }}} */ -/* {{{ proto SQLite3Result SQLite3::querySingle(String Query [, entire_row = false]) +/* {{{ proto SQLite3Result SQLite3::querySingle(String Query [, bool entire_row = false]) Returns a string of the first column, or an array of the entire row. */ PHP_METHOD(sqlite3, querySingle) { @@ -1063,6 +1063,8 @@ return; } + SQLITE3_CHECK_INITIALIZED(stmt_obj-initialised, SQLite3) + if (stmt_obj-bound_params) { zend_hash_internal_pointer_reset(stmt_obj-bound_params); while (zend_hash_get_current_data(stmt_obj-bound_params, (void **)param) == SUCCESS) { @@ -1167,6 +1169,47 @@ } /* }}} */ +/* {{{ proto int SQLite3Stmt::__construct(SQLite3 dbobject, String Statement) + __constructor for SQLite3Stmt. */ +PHP_METHOD(sqlite3stmt, __construct) +{ + php_sqlite3_stmt *stmt_obj; + php_sqlite3_db_object *db_obj; + zval *object = getThis(); + zval *db_zval; + stmt_obj = (php_sqlite3_stmt *)zend_object_store_get_object(object TSRMLS_CC); + char *sql; + int sql_len, errcode; + + zend_replace_error_handling(EH_THROW, NULL, NULL TSRMLS_CC); + + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, Os, db_zval, php_sqlite3_sc_entry, sql, sql_len) == FAILURE) { + return; + } + + db_obj = (php_sqlite3_db_object *)zend_object_store_get_object(db_zval TSRMLS_CC); + + SQLITE3_CHECK_INITIALIZED(db_obj-initialised, SQLite3) + + if (!sql_len) { + RETURN_FALSE; + } + + stmt_obj-db_obj = db_obj; + stmt_obj-db_obj_zval = db_zval; + + Z_ADDREF_P(db_zval); + + errcode = sqlite3_prepare_v2(db_obj-db, sql, sql_len, (stmt_obj-stmt), NULL); + if (errcode != SQLITE_OK) { + php_error_docref(NULL TSRMLS_CC, E_WARNING, Unable to prepare statement: %d, %s, errcode, sqlite3_errmsg(db_obj-db)); + zval_dtor(return_value); + RETURN_FALSE; + } + stmt_obj-initialised = 1; +} +/* }}} */ + /* {{{ proto int SQLite3Result::numColumns() Number of columns in the result set. */ PHP_METHOD(sqlite3result, numColumns) @@ -1327,6 +1370,21 @@ } /* }}} */ +/* {{{ proto int SQLite3Result::__construct() + __constructor for SQLite3Result. */ +PHP_METHOD(sqlite3result, __construct) +{ + php_sqlite3_result *result_obj; + zval *object = getThis(); + result_obj = (php_sqlite3_result *)zend_object_store_get_object(object TSRMLS_CC); + + zend_replace_error_handling(EH_THROW, NULL, NULL TSRMLS_CC); + + php_error_docref(NULL TSRMLS_CC, E_WARNING, SQLite3Result cannot be directly instantiated); + +} +/* }}} */ + /* {{{ arginfo */ ZEND_BEGIN_ARG_INFO(arginfo_sqlite3_open, 0) ZEND_ARG_INFO(0, filename) @@ -1417,6 +1475,10 @@ ZEND_ARG_INFO(0, type) ZEND_END_ARG_INFO() +ZEND_BEGIN_ARG_INFO(arginfo_sqlite3stmt_construct, 1) + ZEND_ARG_INFO(0, sqlite3) +ZEND_END_ARG_INFO() + ZEND_BEGIN_ARG_INFO(arginfo_sqlite3result_numcolumns, 0) ZEND_END_ARG_INFO() @@ -1437,6 +1499,9 @@ ZEND_BEGIN_ARG_INFO(arginfo_sqlite3result_finalize, 0) ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_INFO(arginfo_sqlite3result_construct, 0) +ZEND_END_ARG_INFO() /* }}} */ /* {{{ php_sqlite3_class_methods */ @@ -1457,7 +1522,7 @@ PHP_ME(sqlite3, createFunction, arginfo_sqlite3_createfunction, ZEND_ACC_PUBLIC) PHP_ME(sqlite3, createAggregate, arginfo_sqlite3_createaggregate, ZEND_ACC_PUBLIC) /* Aliases */ - PHP_MALIAS(sqlite3, __construct, open, arginfo_sqlite3_open, ZEND_ACC_PUBLIC) + PHP_MALIAS(sqlite3, __construct, open, arginfo_sqlite3_open, ZEND_ACC_PUBLIC|ZEND_ACC_CTOR) {NULL, NULL, NULL} }; /* }}} */ @@ -1471,6 +1536,7 @@ PHP_ME(sqlite3stmt, execute,arginfo_sqlite3stmt_execute, ZEND_ACC_PUBLIC) PHP_ME(sqlite3stmt, bindParam, arginfo_sqlite3stmt_bindparam, ZEND_ACC_PUBLIC) PHP_ME(sqlite3stmt, bindValue,
[PHP-CVS] cvs: php-src(PHP_5_3) /ext/sqlite3 sqlite3.c /ext/sqlite3/tests sqlite3_23_escape_string.phpt
scottmacTue Sep 30 11:14:48 2008 UTC Modified files: (Branch: PHP_5_3) /php-src/ext/sqlite3sqlite3.c /php-src/ext/sqlite3/tests sqlite3_23_escape_string.phpt Log: MFH: SQLite3::escapeString can be static as it doesn't rely on an instance of SQLite http://cvs.php.net/viewvc.cgi/php-src/ext/sqlite3/sqlite3.c?r1=1.1.2.11r2=1.1.2.12diff_format=u Index: php-src/ext/sqlite3/sqlite3.c diff -u php-src/ext/sqlite3/sqlite3.c:1.1.2.11 php-src/ext/sqlite3/sqlite3.c:1.1.2.12 --- php-src/ext/sqlite3/sqlite3.c:1.1.2.11 Mon Sep 15 00:55:37 2008 +++ php-src/ext/sqlite3/sqlite3.c Tue Sep 30 11:14:48 2008 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: sqlite3.c,v 1.1.2.11 2008/09/15 00:55:37 scottmac Exp $ */ +/* $Id: sqlite3.c,v 1.1.2.12 2008/09/30 11:14:48 scottmac Exp $ */ #ifdef HAVE_CONFIG_H #include config.h @@ -1478,7 +1478,7 @@ PHP_ME(sqlite3, lastErrorMsg, arginfo_sqlite3_lasterrormsg, ZEND_ACC_PUBLIC) PHP_ME(sqlite3, loadExtension, arginfo_sqlite3_loadextension, ZEND_ACC_PUBLIC) PHP_ME(sqlite3, changes, arginfo_sqlite3_changes, ZEND_ACC_PUBLIC) - PHP_ME(sqlite3, escapeString, arginfo_sqlite3_escapestring, ZEND_ACC_PUBLIC) + PHP_ME(sqlite3, escapeString, arginfo_sqlite3_escapestring, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC) PHP_ME(sqlite3, prepare, arginfo_sqlite3_prepare, ZEND_ACC_PUBLIC) PHP_ME(sqlite3, query, arginfo_sqlite3_query, ZEND_ACC_PUBLIC) PHP_ME(sqlite3, querySingle, arginfo_sqlite3_querysingle, ZEND_ACC_PUBLIC) http://cvs.php.net/viewvc.cgi/php-src/ext/sqlite3/tests/sqlite3_23_escape_string.phpt?r1=1.1.2.2r2=1.1.2.3diff_format=u Index: php-src/ext/sqlite3/tests/sqlite3_23_escape_string.phpt diff -u php-src/ext/sqlite3/tests/sqlite3_23_escape_string.phpt:1.1.2.2 php-src/ext/sqlite3/tests/sqlite3_23_escape_string.phpt:1.1.2.3 --- php-src/ext/sqlite3/tests/sqlite3_23_escape_string.phpt:1.1.2.2 Sun Jul 27 00:05:36 2008 +++ php-src/ext/sqlite3/tests/sqlite3_23_escape_string.phpt Tue Sep 30 11:14:48 2008 @@ -12,7 +12,7 @@ var_dump($db-exec('CREATE TABLE test (time INTEGER, id STRING)')); echo INSERT into table\n; -var_dump($db-exec(INSERT INTO test (time, id) VALUES ( . TIMENOW . , ' . $db-escapeString(test''%) . '))); +var_dump($db-exec(INSERT INTO test (time, id) VALUES ( . TIMENOW . , ' . SQLite3::escapeString(test''%) . '))); var_dump($db-exec(INSERT INTO test (time, id) VALUES ( . TIMENOW . , 'b'))); echo SELECTING results\n; -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src(PHP_5_3) /ext/sqlite3 sqlite3.c /ext/sqlite3/tests bug45798.phpt
felipe Tue Aug 12 13:37:32 2008 UTC Added files: (Branch: PHP_5_3) /php-src/ext/sqlite3/tests bug45798.phpt Modified files: /php-src/ext/sqlite3sqlite3.c Log: - MFH: Fixed bug #45798 (sqlite3 doesn't notice if variable was bound) http://cvs.php.net/viewvc.cgi/php-src/ext/sqlite3/sqlite3.c?r1=1.1.2.9r2=1.1.2.10diff_format=u Index: php-src/ext/sqlite3/sqlite3.c diff -u php-src/ext/sqlite3/sqlite3.c:1.1.2.9 php-src/ext/sqlite3/sqlite3.c:1.1.2.10 --- php-src/ext/sqlite3/sqlite3.c:1.1.2.9 Sat Aug 2 04:46:06 2008 +++ php-src/ext/sqlite3/sqlite3.c Tue Aug 12 13:37:32 2008 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: sqlite3.c,v 1.1.2.9 2008/08/02 04:46:06 felipe Exp $ */ +/* $Id: sqlite3.c,v 1.1.2.10 2008/08/12 13:37:32 felipe Exp $ */ #ifdef HAVE_CONFIG_H #include config.h @@ -1069,6 +1069,7 @@ /* If the ZVAL is null then it should be bound as that */ if (Z_TYPE_P(param-parameter) == IS_NULL) { sqlite3_bind_null(stmt_obj-stmt, param-param_number); + zend_hash_move_forward(stmt_obj-bound_params); continue; } http://cvs.php.net/viewvc.cgi/php-src/ext/sqlite3/tests/bug45798.phpt?view=markuprev=1.1 Index: php-src/ext/sqlite3/tests/bug45798.phpt +++ php-src/ext/sqlite3/tests/bug45798.phpt --TEST-- Bug #45798 (sqlite3 doesn't notice if variable was bound) --SKIPIF-- ?php require_once(dirname(__FILE__) . '/skipif.inc'); ? --FILE-- ?php require_once(dirname(__FILE__) . '/new_db.inc'); $db-exec('CREATE TABLE test (time INTEGER, id STRING)'); $db-exec(INSERT INTO test (time, id) VALUES ( . time() . , 'a')); $db-exec(INSERT INTO test (time, id) VALUES ( . time() . , 'b')); $stmt = $db-prepare(SELECT * FROM test WHERE id = ? ORDER BY id ASC); $stmt-bindParam(1, $foo, SQLITE3_TEXT); $results = $stmt-execute(); while ($result = $results-fetchArray(SQLITE3_NUM)) { var_dump($result); } $results-finalize(); $db-close(); print done; ? --EXPECT-- done -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src(PHP_5_3) /ext/sqlite3 sqlite3.c
scottmacThu Jul 31 16:31:13 2008 UTC Modified files: (Branch: PHP_5_3) /php-src/ext/sqlite3sqlite3.c Log: Stray RETURN_TRUE value http://cvs.php.net/viewvc.cgi/php-src/ext/sqlite3/sqlite3.c?r1=1.1.2.5r2=1.1.2.6diff_format=u Index: php-src/ext/sqlite3/sqlite3.c diff -u php-src/ext/sqlite3/sqlite3.c:1.1.2.5 php-src/ext/sqlite3/sqlite3.c:1.1.2.6 --- php-src/ext/sqlite3/sqlite3.c:1.1.2.5 Tue Jul 29 00:56:53 2008 +++ php-src/ext/sqlite3/sqlite3.c Thu Jul 31 16:31:12 2008 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: sqlite3.c,v 1.1.2.5 2008/07/29 00:56:53 scottmac Exp $ */ +/* $Id: sqlite3.c,v 1.1.2.6 2008/07/31 16:31:12 scottmac Exp $ */ #ifdef HAVE_CONFIG_H #include config.h @@ -149,7 +149,6 @@ zend_llist_clean((db_obj-free_list)); errcode = sqlite3_close(db_obj-db); if (errcode != SQLITE_OK) { - RETURN_TRUE; php_error_docref(NULL TSRMLS_CC, E_WARNING, Unable to close database: %d, %s, errcode, sqlite3_errmsg(db_obj-db)); RETURN_FALSE; } -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src(PHP_5_3) /ext/sqlite3 sqlite3.c
scottmacThu Jul 31 22:30:26 2008 UTC Modified files: (Branch: PHP_5_3) /php-src/ext/sqlite3sqlite3.c Log: Class rename to match Coding Standards http://cvs.php.net/viewvc.cgi/php-src/ext/sqlite3/sqlite3.c?r1=1.1.2.6r2=1.1.2.7diff_format=u Index: php-src/ext/sqlite3/sqlite3.c diff -u php-src/ext/sqlite3/sqlite3.c:1.1.2.6 php-src/ext/sqlite3/sqlite3.c:1.1.2.7 --- php-src/ext/sqlite3/sqlite3.c:1.1.2.6 Thu Jul 31 16:31:12 2008 +++ php-src/ext/sqlite3/sqlite3.c Thu Jul 31 22:30:26 2008 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: sqlite3.c,v 1.1.2.6 2008/07/31 16:31:12 scottmac Exp $ */ +/* $Id: sqlite3.c,v 1.1.2.7 2008/07/31 22:30:26 scottmac Exp $ */ #ifdef HAVE_CONFIG_H #include config.h @@ -360,7 +360,7 @@ } /* }}} */ -/* {{{ proto sqlite3_stmt SQLite3::prepare(String Query) +/* {{{ proto SQLite3Stmt SQLite3::prepare(String Query) Returns a prepared SQL statement for execution. */ PHP_METHOD(sqlite3, prepare) { @@ -398,8 +398,8 @@ } /* }}} */ -/* {{{ proto sqlite3_result SQLite3::query(String Query) - Returns true or false, for queries that return data it will return a sqlite3_result object. */ +/* {{{ proto SQLite3Result SQLite3::query(String Query) + Returns true or false, for queries that return data it will return a SQLite3Result object. */ PHP_METHOD(sqlite3, query) { php_sqlite3_db_object *db_obj; @@ -511,7 +511,7 @@ } /* }}} */ -/* {{{ proto sqlite3_result SQLite3::querySingle(String Query [, entire_row = false]) +/* {{{ proto SQLite3Result SQLite3::querySingle(String Query [, entire_row = false]) Returns a string of the first column, or an array of the entire row. */ PHP_METHOD(sqlite3, querySingle) { @@ -864,9 +864,9 @@ } /* }}} */ -/* {{{ proto int SQLite3_stmt::paramCount() +/* {{{ proto int SQLite3Stmt::paramCount() Returns the number of parameters within the prepared statement. */ -PHP_METHOD(sqlite3_stmt, paramCount) +PHP_METHOD(sqlite3stmt, paramCount) { php_sqlite3_stmt *stmt_obj; zval *object = getThis(); @@ -880,9 +880,9 @@ } /* }}} */ -/* {{{ proto bool SQLite3_stmt::close() +/* {{{ proto bool SQLite3Stmt::close() Closes the prepared statement. */ -PHP_METHOD(sqlite3_stmt, close) +PHP_METHOD(sqlite3stmt, close) { php_sqlite3_stmt *stmt_obj; zval *object = getThis(); @@ -898,9 +898,9 @@ } /* }}} */ -/* {{{ proto bool SQLite3_stmt::reset() +/* {{{ proto bool SQLite3Stmt::reset() Reset the prepared statement to the state before it was executed, bindings still remain. */ -PHP_METHOD(sqlite3_stmt, reset) +PHP_METHOD(sqlite3stmt, reset) { php_sqlite3_stmt *stmt_obj; zval *object = getThis(); @@ -918,9 +918,9 @@ } /* }}} */ -/* {{{ proto bool SQLite3_stmt::clear() +/* {{{ proto bool SQLite3Stmt::clear() Clear all current bound parameters. */ -PHP_METHOD(sqlite3_stmt, clear) +PHP_METHOD(sqlite3stmt, clear) { php_sqlite3_stmt *stmt_obj; zval *object = getThis(); @@ -984,9 +984,9 @@ } /* }}} */ -/* {{{ proto bool SQLite3_stmt::bindParam(int parameter_number, mixed parameter [, int type]) +/* {{{ proto bool SQLite3Stmt::bindParam(int parameter_number, mixed parameter [, int type]) Bind Paramater to a stmt variable. */ -PHP_METHOD(sqlite3_stmt, bindParam) +PHP_METHOD(sqlite3stmt, bindParam) { php_sqlite3_stmt *stmt_obj; zval *object = getThis(); @@ -1015,9 +1015,9 @@ } /* }}} */ -/* {{{ proto bool SQLite3_stmt::bindValue(int parameter_number, mixed parameter [, int type]) +/* {{{ proto bool SQLite3Stmt::bindValue(int parameter_number, mixed parameter [, int type]) Bind Value of a parameter to a stmt variable. */ -PHP_METHOD(sqlite3_stmt, bindValue) +PHP_METHOD(sqlite3stmt, bindValue) { php_sqlite3_stmt *stmt_obj; zval *object = getThis(); @@ -1046,9 +1046,9 @@ } /* }}} */ -/* {{{ proto SQLite3_result SQLite3_stmt::execute() +/* {{{ proto SQLite3Result SQLite3Stmt::execute() Executes a prepared statement and returns a result set object. */ -PHP_METHOD(sqlite3_stmt, execute) +PHP_METHOD(sqlite3stmt, execute) { php_sqlite3_stmt *stmt_obj; php_sqlite3_result *result; @@ -1164,15 +1164,15 @@ } /* }}} */ -/* {{{ proto int SQLite3_result::numColumns() +/* {{{ proto int SQLite3Result::numColumns() Number of columns in the result set. */ -PHP_METHOD(sqlite3_result, numColumns) +PHP_METHOD(sqlite3result, numColumns) { php_sqlite3_result *result_obj; zval *object = getThis(); result_obj = (php_sqlite3_result *)zend_object_store_get_object(object TSRMLS_CC); - SQLITE3_CHECK_INITIALIZED(result_obj-stmt_obj-initialised, SQLite3_result) + SQLITE3_CHECK_INITIALIZED(result_obj-stmt_obj-initialised, SQLite3Result) if (zend_parse_parameters_none() == FAILURE) { return; @@ -1182,16 +1182,16
[PHP-CVS] cvs: php-src(PHP_5_3) /ext/sqlite3 sqlite3.c
scottmacMon Jul 28 23:01:02 2008 UTC Modified files: (Branch: PHP_5_3) /php-src/ext/sqlite3sqlite3.c Log: Fix error when fetchArray reaches the last row, and prototyp error http://cvs.php.net/viewvc.cgi/php-src/ext/sqlite3/sqlite3.c?r1=1.1.2.3r2=1.1.2.4diff_format=u Index: php-src/ext/sqlite3/sqlite3.c diff -u php-src/ext/sqlite3/sqlite3.c:1.1.2.3 php-src/ext/sqlite3/sqlite3.c:1.1.2.4 --- php-src/ext/sqlite3/sqlite3.c:1.1.2.3 Sat Jul 26 23:58:06 2008 +++ php-src/ext/sqlite3/sqlite3.c Mon Jul 28 23:01:02 2008 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: sqlite3.c,v 1.1.2.3 2008/07/26 23:58:06 jani Exp $ */ +/* $Id: sqlite3.c,v 1.1.2.4 2008/07/28 23:01:02 scottmac Exp $ */ #ifdef HAVE_CONFIG_H #include config.h @@ -1013,7 +1013,7 @@ } /* }}} */ -/* {{{ proto bool SQLite3_stmt::bindValue(inte parameter_number, mixed parameter [, int type]) +/* {{{ proto bool SQLite3_stmt::bindValue(int parameter_number, mixed parameter [, int type]) Bind Value of a parameter to a stmt variable. */ PHP_METHOD(sqlite3_stmt, bindValue) { @@ -1252,9 +1252,11 @@ add_assoc_zval(return_value, (char*)sqlite3_column_name(result_obj-stmt_obj-stmt, i), data); } } - break; + break; + case SQLITE_DONE: RETURN_FALSE; + break; default: php_error_docref(NULL TSRMLS_CC, E_WARNING, Unable to execute statement: %s, sqlite3_errmsg(sqlite3_db_handle(result_obj-stmt_obj-stmt))); -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php