]> granicus.if.org Git - php/commitdiff
Added sqlite_fetch_column_types() 3rd argument for arrays.
authorIlia Alshanetsky <iliaa@php.net>
Thu, 14 Oct 2004 23:19:38 +0000 (23:19 +0000)
committerIlia Alshanetsky <iliaa@php.net>
Thu, 14 Oct 2004 23:19:38 +0000 (23:19 +0000)
NEWS
ext/sqlite/sqlite.c

diff --git a/NEWS b/NEWS
index 3747e4cb041ee222672e99989dfcf0ccff213ea5..698a6f548a7ab75721ed9b717afa316bbac427b8 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -1,6 +1,7 @@
 PHP                                                                        NEWS
 |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
 ?? ??? 2004, PHP 5.1.0
+- Added sqlite_fetch_column_types() 3rd argument for arrays. (Ilia)
 - Added optional offset parameter to stream_get_contents() and 
   file_get_contents(). (Ilia)
 - Improved performance of:
index e51100a6d698b2c50f1793c6d04998e7ddcefe22..b8fa042947bbcab892e367e9fe852392554cb880 100644 (file)
@@ -1569,7 +1569,7 @@ PHP_FUNCTION(sqlite_unbuffered_query)
 }
 /* }}} */
 
-/* {{{ proto resource sqlite_fetch_column_types(string table_name, resource db)
+/* {{{ proto resource sqlite_fetch_column_types(string table_name, [, int result_type] resource db)
    Return an array of column types from a particular table. */
 PHP_FUNCTION(sqlite_fetch_column_types)
 {
@@ -1581,10 +1581,10 @@ PHP_FUNCTION(sqlite_fetch_column_types)
        zval *object = getThis();
        struct php_sqlite_result res;
        const char **rowdata, **colnames, *tail;
-       int i, ncols;
+       int i, ncols, result_type = PHPSQLITE_ASSOC;
 
        if (object) {
-               if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &tbl, &tbl_len)) {
+               if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|l", &tbl, &tbl_len, &result_type)) {
                        return;
                }
                DB_FROM_OBJECT(db, object);
@@ -1627,7 +1627,12 @@ PHP_FUNCTION(sqlite_fetch_column_types)
                        php_sqlite_strtolower(colname);
                }
 
-               add_assoc_string(return_value, colname, colnames[ncols + i] ? (char *)colnames[ncols + i] : "", 1);
+               if (result_type == PHPSQLITE_ASSOC) {
+                       add_assoc_string(return_value, colname, colnames[ncols + i] ? (char *)colnames[ncols + i] : "", 1);
+               }
+               if (result_type == PHPSQLITE_NUM) {
+                       add_index_string(return_value, i, colnames[ncols + i] ? (char *)colnames[ncols + i] : "", 1);
+               }
        }
 
 done: