cvs: php-src /ext/sqlite php_sqlite.h sqlite.c

From: Date: Mon, 10 Jan 2005 07:13:56 +0000
Subject: cvs: php-src /ext/sqlite php_sqlite.h sqlite.c
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-29842@lists.php.net to get a copy of this message
helly Mon Jan 10 02:13:56 2005 EDT Modified files: /php-src/ext/sqlite php_sqlite.h sqlite.c Log: - Implement iterator interface in sqlite http://cvs.php.net/diff.php/php-src/ext/sqlite/php_sqlite.h?r1=1.30&r2=1.31&ty=u Index: php-src/ext/sqlite/php_sqlite.h diff -u php-src/ext/sqlite/php_sqlite.h:1.30 php-src/ext/sqlite/php_sqlite.h:1.31 --- php-src/ext/sqlite/php_sqlite.h:1.30 Thu May 13 10:19:10 2004 +++ php-src/ext/sqlite/php_sqlite.h Mon Jan 10 02:13:56 2005 @@ -17,7 +17,7 @@ | Marcus Boerger <helly@php.net> | +----------------------------------------------------------------------+ - $Id: php_sqlite.h,v 1.30 2004/05/13 14:19:10 stas Exp $ + $Id: php_sqlite.h,v 1.31 2005/01/10 07:13:56 helly Exp $ */ #ifndef PHP_SQLITE_H @@ -65,6 +65,7 @@ PHP_FUNCTION(sqlite_rewind); PHP_FUNCTION(sqlite_next); PHP_FUNCTION(sqlite_prev); +PHP_FUNCTION(sqlite_key); PHP_FUNCTION(sqlite_valid); PHP_FUNCTION(sqlite_has_prev); http://cvs.php.net/diff.php/php-src/ext/sqlite/sqlite.c?r1=1.151&r2=1.152&ty=u Index: php-src/ext/sqlite/sqlite.c diff -u php-src/ext/sqlite/sqlite.c:1.151 php-src/ext/sqlite/sqlite.c:1.152 --- php-src/ext/sqlite/sqlite.c:1.151 Fri Nov 26 08:17:30 2004 +++ php-src/ext/sqlite/sqlite.c Mon Jan 10 02:13:56 2005 @@ -17,7 +17,7 @@ | Marcus Boerger <helly@php.net> | +----------------------------------------------------------------------+ - $Id: sqlite.c,v 1.151 2004/11/26 13:17:30 stas Exp $ + $Id: sqlite.c,v 1.152 2005/01/10 07:13:56 helly Exp $ */ #ifdef HAVE_CONFIG_H @@ -42,6 +42,7 @@ #include <sqlite.h> #include "zend_exceptions.h" +#include "zend_interfaces.h" #ifndef safe_emalloc # define safe_emalloc(a,b,c) emalloc((a)*(b)+(c)) @@ -223,11 +224,11 @@ PHP_ME_MAPPING(column, sqlite_column, NULL) PHP_ME_MAPPING(numFields, sqlite_num_fields, NULL) PHP_ME_MAPPING(fieldName, sqlite_field_name, NULL) - /* spl_forward */ + /* iterator */ PHP_ME_MAPPING(current, sqlite_current, NULL) + PHP_ME_MAPPING(key, sqlite_key, NULL) PHP_ME_MAPPING(next, sqlite_next, NULL) PHP_ME_MAPPING(valid, sqlite_valid, NULL) - /* spl_sequence */ PHP_ME_MAPPING(rewind, sqlite_rewind, NULL) /* additional */ PHP_ME_MAPPING(prev, sqlite_prev, NULL) @@ -245,7 +246,7 @@ PHP_ME_MAPPING(column, sqlite_column, NULL) PHP_ME_MAPPING(numFields, sqlite_num_fields, NULL) PHP_ME_MAPPING(fieldName, sqlite_field_name, NULL) - /* spl_forward */ + /* iterator */ PHP_ME_MAPPING(current, sqlite_current, NULL) PHP_ME_MAPPING(next, sqlite_next, NULL) PHP_ME_MAPPING(valid, sqlite_valid, NULL) @@ -1000,10 +1001,11 @@ REGISTER_SQLITE_CLASS(Exception, exception, zend_exception_get_default()); sqlite_object_handlers_query.get_class_entry = sqlite_get_ce_query; sqlite_object_handlers_ub_query.get_class_entry = sqlite_get_ce_ub_query; - + sqlite_ce_ub_query->get_iterator = sqlite_get_iterator; sqlite_ce_ub_query->iterator_funcs.funcs = &sqlite_ub_query_iterator_funcs; + zend_class_implements(sqlite_ce_query TSRMLS_CC, 1, zend_ce_iterator); sqlite_ce_query->get_iterator = sqlite_get_iterator; sqlite_ce_query->iterator_funcs.funcs = &sqlite_query_iterator_funcs; @@ -1071,7 +1073,7 @@ { php_info_print_table_start(); php_info_print_table_header(2, "SQLite support", "enabled"); - php_info_print_table_row(2, "PECL Module version", PHP_SQLITE_MODULE_VERSION " $Id: sqlite.c,v 1.151 2004/11/26 13:17:30 stas Exp $"); + php_info_print_table_row(2, "PECL Module version", PHP_SQLITE_MODULE_VERSION " $Id: sqlite.c,v 1.152 2005/01/10 07:13:56 helly Exp $"); php_info_print_table_row(2, "SQLite Library", sqlite_libversion()); php_info_print_table_row(2, "SQLite Encoding", sqlite_libencoding()); php_info_print_table_end(); @@ -2630,6 +2632,30 @@ } /* }}} */ +/* {{{ proto bool sqlite_key(resource result) + Return the current row index of a buffered result. */ +PHP_FUNCTION(sqlite_key) +{ + zval *zres; + struct php_sqlite_result *res; + zval *object = getThis(); + + if (object) { + if (ZEND_NUM_ARGS() != 0) { + WRONG_PARAM_COUNT + } + RES_FROM_OBJECT(res, object); + } else { + if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r", &zres)) { + return; + } + ZEND_FETCH_RESOURCE(res, struct php_sqlite_result *, &zres, -1, "sqlite result", le_sqlite_result); + } + + RETURN_LONG(res->curr_row); +} +/* }}} */ + /* {{{ proto bool sqlite_prev(resource result) * Seek to the previous row number of a result set. */ PHP_FUNCTION(sqlite_prev)

« previous php.cvs (#29842) next »