]> granicus.if.org Git - php/commitdiff
merge other PDO fixes from 5.1 branch.
authorWez Furlong <wez@php.net>
Sun, 11 Sep 2005 05:08:49 +0000 (05:08 +0000)
committerWez Furlong <wez@php.net>
Sun, 11 Sep 2005 05:08:49 +0000 (05:08 +0000)
Allow pdo_sqlite to build against 5.0 and 5.1 too.

ext/pdo_mysql/mysql_driver.c
ext/pdo_oci/oci_driver.c
ext/pdo_pgsql/pgsql_statement.c
ext/pdo_sqlite/sqlite_driver.c

index 5fdd4436222827b4e8e24cb467689dacc470b56b..75c7fc2cac817c3013b54bf27c1286b034331c70 100755 (executable)
@@ -424,7 +424,7 @@ static int pdo_mysql_handle_factory(pdo_dbh_t *dbh, zval *driver_options TSRMLS_
        }
 
        dbname = vars[1].optval;
-    host = vars[2].optval;     
+       host = vars[2].optval;  
        if(vars[3].optval) {
                port = atoi(vars[3].optval);
        }
index 3424ebedb82ccc3d72b34c913c62497e83e6dcdc..706faebf38510a99ae6c64089eb9b9ed47b23bdb 100755 (executable)
@@ -144,6 +144,18 @@ ub4 _oci_error(OCIError *err, pdo_dbh_t *dbh, pdo_stmt_t *stmt, char *what, swor
                }
        }
 
+       if (stmt) {
+               /* always propogate the error code back up to the dbh,
+                * so that we can catch the error information when execute
+                * is called via query.  See Bug #33707 */
+               if (H->einfo.errmsg) {
+                       efree(H->einfo.errmsg);
+               }
+               H->einfo = *einfo;
+               H->einfo.errmsg = einfo->errmsg ? estrdup(einfo->errmsg) : NULL;
+               strcpy(dbh->error_code, stmt->error_code);
+       }
+
        /* little mini hack so that we can use this code from the dbh ctor */
        if (!dbh->methods) {
                zend_throw_exception_ex(php_pdo_get_exception(TSRMLS_C), 0 TSRMLS_CC, "SQLSTATE[%s]: %s", *pdo_err, einfo->errmsg);
index 9e6420eeb48e9cb5bd85a35e522887bb7db646dd..88e0e4620fd46e299bc9f0d86e332807bbaacf25 100644 (file)
@@ -203,6 +203,10 @@ static int pgsql_stmt_param_hook(pdo_stmt_t *stmt, struct pdo_bound_param_data *
                                                        Z_TYPE_P(param->parameter) == IS_NULL) {
                                                S->param_values[param->paramno] = NULL;
                                                S->param_lengths[param->paramno] = 0;
+                                       } else if (Z_TYPE_P(param->parameter) == IS_BOOL) {
+                                               S->param_values[param->paramno] = Z_BVAL_P(param->parameter) ? "t" : "f";
+                                               S->param_lengths[param->paramno] = 1;
+                                               S->param_formats[param->paramno] = 1;
                                        } else {
                                                convert_to_string(param->parameter);
                                                S->param_values[param->paramno] = Z_STRVAL_P(param->parameter);
index a93aec9eeff0f3d9ff22c104fb4e8b9513ab02aa..65790750f64277986708012606274bf38809e237 100644 (file)
@@ -457,7 +457,11 @@ static PHP_METHOD(SQLite, sqliteCreateFunction)
        char *func_name;
        int func_name_len;
        long argc = -1;
+#ifdef IS_UNICODE
        zval cbname;
+#else
+       char *cbname;
+#endif
        pdo_dbh_t *dbh;
        pdo_sqlite_db_handle *H;
        int ret;
@@ -470,11 +474,20 @@ static PHP_METHOD(SQLite, sqliteCreateFunction)
        dbh = zend_object_store_get_object(getThis() TSRMLS_CC);
 
        if (!zend_is_callable(callback, 0, &cbname)) {
+#ifdef IS_UNICODE
                php_error_docref(NULL TSRMLS_CC, E_WARNING, "function '%R' is not callable", Z_TYPE(cbname), Z_UNIVAL(cbname));
                zval_dtor(&cbname);
+#else
+               php_error_docref(NULL TSRMLS_CC, E_WARNING, "function '%s' is not callable", cbname);
+               efree(cbname);
+#endif
                RETURN_FALSE;
        }
+#ifdef IS_UNICODE
        zval_dtor(&cbname);
+#else
+       efree(cbname);
+#endif
        
        H = (pdo_sqlite_db_handle *)dbh->driver_data;
 
@@ -528,7 +541,11 @@ static PHP_METHOD(SQLite, sqliteCreateAggregate)
        char *func_name;
        int func_name_len;
        long argc = -1;
+#ifdef IS_UNICODE
        zval cbname;
+#else
+       char *cbname;
+#endif
        pdo_dbh_t *dbh;
        pdo_sqlite_db_handle *H;
        int ret;
@@ -541,17 +558,35 @@ static PHP_METHOD(SQLite, sqliteCreateAggregate)
        dbh = zend_object_store_get_object(getThis() TSRMLS_CC);
 
        if (!zend_is_callable(step_callback, 0, &cbname)) {
+#ifdef IS_UNICODE
                php_error_docref(NULL TSRMLS_CC, E_WARNING, "function '%R' is not callable", Z_TYPE(cbname), Z_UNIVAL(cbname));
                zval_dtor(&cbname);
+#else
+               php_error_docref(NULL TSRMLS_CC, E_WARNING, "function '%s' is not callable", cbname);
+               efree(cbname);
+#endif
                RETURN_FALSE;
        }
+#ifdef IS_UNICODE
        zval_dtor(&cbname);
+#else
+       efree(cbname);
+#endif
        if (!zend_is_callable(fini_callback, 0, &cbname)) {
+#ifdef IS_UNICODE
                php_error_docref(NULL TSRMLS_CC, E_WARNING, "function '%R' is not callable", Z_TYPE(cbname), Z_UNIVAL(cbname));
                zval_dtor(&cbname);
+#else
+               php_error_docref(NULL TSRMLS_CC, E_WARNING, "function '%s' is not callable", cbname);
+               efree(cbname);
+#endif
                RETURN_FALSE;
        }
+#ifdef IS_UNICODE
        zval_dtor(&cbname);
+#else
+       efree(cbname);
+#endif
        
        H = (pdo_sqlite_db_handle *)dbh->driver_data;