The attached patch adds basic support for storing properly-typed integer and boolean data in SQLite3 databases. I don't really understand why this kind of support has been so consistently lacking in PHP database driver implementations. Similar problems have plagued the MySQL and MySQLi extensions for a long time, and PDO seems to struggle for the support at times. This diff is against PHP 5.2.3, but I've verified that it works in 5.2.4RC3, 5.2.4 CVS, and HEAD. This by itself disturbs me because it indicates that in all this time this code hasn't been touched at all. Was it really that hard to add this very simple code?

-- Gwynne, Daughter of the Code
"This whole world is an asylum for the incurable."


Index: ext/pdo_sqlite/sqlite_statement.c
===================================================================
RCS file: /repository/php-src/ext/pdo_sqlite/sqlite_statement.c,v
retrieving revision 1.18.2.4.2.2
diff -u -r1.18.2.4.2.2 sqlite_statement.c
--- ext/pdo_sqlite/sqlite_statement.c 1 Jan 2007 09:36:05 -0000 1.18.2.4.2.2
+++ ext/pdo_sqlite/sqlite_statement.c   27 Aug 2007 10:08:42 -0000
@@ -96,7 +96,22 @@
                                switch (PDO_PARAM_TYPE(param->param_type)) {
                                        case PDO_PARAM_STMT:
                                                return 0;
-
+                               
+                                       case PDO_PARAM_INT:
+                                       case PDO_PARAM_BOOL:
+                                               if (Z_TYPE_P(param->parameter) 
== IS_NULL) {
+ if (sqlite3_bind_null(S->stmt, param->paramno + 1) == SQLITE_OK) {
+                                                               return 1;
+                                                       }
+                                               } else {
+                                                       
convert_to_long(param->parameter);
+ if (SQLITE_OK == sqlite3_bind_int(S->stmt, param->paramno + 1, Z_LVAL_P(param->parameter))) {
+                                                               return 1;
+                                                       }
+                                               }
+                                               pdo_sqlite_error_stmt(stmt);
+                                               return 0;
+
                                        case PDO_PARAM_NULL:
                                                if (sqlite3_bind_null(S->stmt, 
param->paramno + 1) == SQLITE_OK) {
                                                        return 1;

--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to