diff options
author | Wez Furlong <wez@php.net> | 2005-01-18 04:58:50 +0000 |
---|---|---|
committer | Wez Furlong <wez@php.net> | 2005-01-18 04:58:50 +0000 |
commit | a9d98544de4a41bba3542b6b5bcd1f18e18af073 (patch) | |
tree | c0e8a0ba950eeb62ff7ed5cf6849a7352f97614e | |
parent | d911f1986230834ccda961860aac784efdea3712 (diff) | |
download | php-git-a9d98544de4a41bba3542b6b5bcd1f18e18af073.tar.gz |
Allow drivers to select bind emulation on a per statement basis
-rwxr-xr-x | ext/pdo/pdo_stmt.c | 3 | ||||
-rwxr-xr-x | ext/pdo/php_pdo_driver.h | 23 | ||||
-rw-r--r-- | ext/pdo_dblib/dblib_driver.c | 2 | ||||
-rw-r--r-- | ext/pdo_firebird/firebird_driver.c | 2 | ||||
-rwxr-xr-x | ext/pdo_mysql/mysql_driver.c | 2 | ||||
-rwxr-xr-x | ext/pdo_oci/oci_driver.c | 2 | ||||
-rwxr-xr-x | ext/pdo_odbc/odbc_driver.c | 2 | ||||
-rw-r--r-- | ext/pdo_pgsql/pgsql_driver.c | 2 | ||||
-rw-r--r-- | ext/pdo_sqlite/sqlite_driver.c | 2 |
9 files changed, 24 insertions, 16 deletions
diff --git a/ext/pdo/pdo_stmt.c b/ext/pdo/pdo_stmt.c index 67c11f4755..a16b5c2365 100755 --- a/ext/pdo/pdo_stmt.c +++ b/ext/pdo/pdo_stmt.c @@ -315,7 +315,8 @@ static PHP_METHOD(PDOStatement, execute) } } - if (!stmt->dbh->supports_placeholders) { + /* TODO: handle the non-native types too... doh. */ + if (PDO_PLACEHOLDER_NONE == stmt->supports_placeholders) { int error_pos; /* handle the emulated parameter binding, * stmt->active_query_string holds the query with binds expanded and diff --git a/ext/pdo/php_pdo_driver.h b/ext/pdo/php_pdo_driver.h index cefa08ee60..1560a3268c 100755 --- a/ext/pdo/php_pdo_driver.h +++ b/ext/pdo/php_pdo_driver.h @@ -35,7 +35,7 @@ struct pdo_bound_param_data; # define FALSE 0 #endif -#define PDO_DRIVER_API 20050111 +#define PDO_DRIVER_API 20050117 enum pdo_param_type { PDO_PARAM_NULL, @@ -326,6 +326,12 @@ typedef int (*pdo_stmt_get_attr_func)(pdo_stmt_t *stmt, long attr, zval *val TSR */ typedef int (*pdo_stmt_get_column_meta_func)(pdo_stmt_t *stmt, long colno, zval *return_value TSRMLS_DC); +/* advances the statement to the next rowset of the batch. + * If it returns 1, PDO will tear down its idea of columns + * and meta data. If it returns 0, PDO will indicate an error + * to the caller. */ +typedef int (*pdo_stmt_next_rowset_func)(pdo_stmt_t *stmt TSRMLS_DC); + struct pdo_stmt_methods { pdo_stmt_dtor_func dtor; pdo_stmt_execute_func executer; @@ -336,6 +342,7 @@ struct pdo_stmt_methods { pdo_stmt_set_attr_func set_attribute; pdo_stmt_get_attr_func get_attribute; pdo_stmt_get_column_meta_func get_column_meta; + pdo_stmt_next_rowset_func next_rowset; }; /* }}} */ @@ -382,11 +389,6 @@ struct _pdo_dbh_t { * the columns that are returned */ unsigned alloc_own_columns:1; - /* if true, the driver supports placeholders and can implement - * bindParam() for its prepared statements, if false, PDO should - * emulate prepare and bind on its behalf */ - unsigned supports_placeholders:2; - /* if true, commit or rollBack is allowed to be called */ unsigned in_txn:1; @@ -398,7 +400,7 @@ struct _pdo_dbh_t { /* the sum of the number of bits here and the bit fields preceeding should * equal 32 */ - unsigned _reserved_flags:21; + unsigned _reserved_flags:23; /* data source string used to open this handle */ const char *data_source; @@ -456,7 +458,12 @@ struct _pdo_stmt_t { /* if true, we've already successfully executed this statement at least * once */ unsigned executed:1; - unsigned _reserved:31; + /* if true, the statement supports placeholders and can implement + * bindParam() for its prepared statements, if false, PDO should + * emulate prepare and bind on its behalf */ + unsigned supports_placeholders:2; + + unsigned _reserved:29; /* the number of columns in the result set; not valid until after * the statement has been executed at least once. In some cases, might diff --git a/ext/pdo_dblib/dblib_driver.c b/ext/pdo_dblib/dblib_driver.c index 5ec3794876..2bb40ce88f 100644 --- a/ext/pdo_dblib/dblib_driver.c +++ b/ext/pdo_dblib/dblib_driver.c @@ -91,6 +91,7 @@ static int dblib_handle_preparer(pdo_dbh_t *dbh, const char *sql, long sql_len, S->H = H; stmt->driver_data = S; stmt->methods = &dblib_stmt_methods; + stmt->supports_placeholders = PDO_PLACEHOLDER_NONE; S->err.sqlstate = stmt->error_code; return 1; @@ -220,7 +221,6 @@ static int pdo_dblib_handle_factory(pdo_dbh_t *dbh, zval *driver_options TSRMLS_ } ret = 1; - dbh->supports_placeholders = 0; dbh->max_escaped_char_length = 2; dbh->alloc_own_columns = 1; diff --git a/ext/pdo_firebird/firebird_driver.c b/ext/pdo_firebird/firebird_driver.c index ccc8550f74..3dce6aea84 100644 --- a/ext/pdo_firebird/firebird_driver.c +++ b/ext/pdo_firebird/firebird_driver.c @@ -182,6 +182,7 @@ static int firebird_handle_preparer(pdo_dbh_t *dbh, const char *sql, long sql_le stmt->driver_data = S; stmt->methods = &firebird_stmt_methods; + stmt->supports_placeholders = PDO_PLACEHOLDER_POSITIONAL; return 1; @@ -626,7 +627,6 @@ static int pdo_firebird_handle_factory(pdo_dbh_t *dbh, zval *driver_options TSRM } dbh->methods = &firebird_methods; - dbh->supports_placeholders = PDO_PLACEHOLDER_POSITIONAL; dbh->native_case = PDO_CASE_UPPER; dbh->alloc_own_columns = 1; diff --git a/ext/pdo_mysql/mysql_driver.c b/ext/pdo_mysql/mysql_driver.c index f0f0da3398..5f7b573b7b 100755 --- a/ext/pdo_mysql/mysql_driver.c +++ b/ext/pdo_mysql/mysql_driver.c @@ -143,6 +143,7 @@ static int mysql_handle_preparer(pdo_dbh_t *dbh, const char *sql, long sql_len, S->H = H; stmt->driver_data = S; stmt->methods = &mysql_stmt_methods; + stmt->supports_placeholders = PDO_PLACEHOLDER_NONE; return 1; } @@ -287,7 +288,6 @@ static int pdo_mysql_handle_factory(pdo_dbh_t *dbh, zval *driver_options TSRMLS_ H->attached = 1; dbh->alloc_own_columns = 1; - dbh->supports_placeholders = 0; dbh->max_escaped_char_length = 2; dbh->methods = &mysql_methods; diff --git a/ext/pdo_oci/oci_driver.c b/ext/pdo_oci/oci_driver.c index 01a79c1699..1e17ae7511 100755 --- a/ext/pdo_oci/oci_driver.c +++ b/ext/pdo_oci/oci_driver.c @@ -240,6 +240,7 @@ static int oci_handle_preparer(pdo_dbh_t *dbh, const char *sql, long sql_len, pd stmt->driver_data = S; stmt->methods = &oci_stmt_methods; + stmt->supports_placeholders = PDO_PLACEHOLDER_NAMED; return 1; } @@ -472,7 +473,6 @@ static int pdo_oci_handle_factory(pdo_dbh_t *dbh, zval *driver_options TSRMLS_DC dbh->methods = &oci_methods; dbh->alloc_own_columns = 1; - dbh->supports_placeholders = PDO_PLACEHOLDER_NAMED; dbh->native_case = PDO_CASE_UPPER; ret = 1; diff --git a/ext/pdo_odbc/odbc_driver.c b/ext/pdo_odbc/odbc_driver.c index 889067f37d..cdd55223f1 100755 --- a/ext/pdo_odbc/odbc_driver.c +++ b/ext/pdo_odbc/odbc_driver.c @@ -171,6 +171,7 @@ static int odbc_handle_preparer(pdo_dbh_t *dbh, const char *sql, long sql_len, p stmt->driver_data = S; stmt->methods = &odbc_stmt_methods; + stmt->supports_placeholders = PDO_PLACEHOLDER_POSITIONAL; return 1; } @@ -357,7 +358,6 @@ static int pdo_odbc_handle_factory(pdo_dbh_t *dbh, zval *driver_options TSRMLS_D dbh->methods = &odbc_methods; dbh->alloc_own_columns = 1; - dbh->supports_placeholders = PDO_PLACEHOLDER_POSITIONAL; return 1; } diff --git a/ext/pdo_pgsql/pgsql_driver.c b/ext/pdo_pgsql/pgsql_driver.c index e60fbc1f87..21c3be7375 100644 --- a/ext/pdo_pgsql/pgsql_driver.c +++ b/ext/pdo_pgsql/pgsql_driver.c @@ -130,6 +130,7 @@ static int pgsql_handle_preparer(pdo_dbh_t *dbh, const char *sql, long sql_len, S->H = H; stmt->driver_data = S; stmt->methods = &pgsql_stmt_methods; + stmt->supports_placeholders = PDO_PLACEHOLDER_NONE; scrollable = pdo_attr_lval(driver_options, PDO_ATTR_CURSOR, PDO_CURSOR_FWDONLY TSRMLS_CC) == PDO_CURSOR_SCROLL; @@ -375,7 +376,6 @@ static int pdo_pgsql_handle_factory(pdo_dbh_t *dbh, zval *driver_options TSRMLS_ dbh->methods = &pgsql_methods; dbh->alloc_own_columns = 1; - dbh->supports_placeholders = PDO_PLACEHOLDER_NONE; dbh->max_escaped_char_length = 2; ret = 1; diff --git a/ext/pdo_sqlite/sqlite_driver.c b/ext/pdo_sqlite/sqlite_driver.c index 391132e619..845acc0856 100644 --- a/ext/pdo_sqlite/sqlite_driver.c +++ b/ext/pdo_sqlite/sqlite_driver.c @@ -122,6 +122,7 @@ static int sqlite_handle_preparer(pdo_dbh_t *dbh, const char *sql, long sql_len, S->H = H; stmt->driver_data = S; stmt->methods = &sqlite_stmt_methods; + stmt->supports_placeholders = PDO_PLACEHOLDER_POSITIONAL; if (PDO_CURSOR_FWDONLY != pdo_attr_lval(driver_options, PDO_ATTR_CURSOR, PDO_CURSOR_FWDONLY TSRMLS_CC)) { H->einfo.errcode = SQLITE_ERROR; @@ -356,7 +357,6 @@ static int pdo_sqlite_handle_factory(pdo_dbh_t *dbh, zval *driver_options TSRMLS sqlite3_busy_timeout(H->db, timeout * 1000); dbh->alloc_own_columns = 1; - dbh->supports_placeholders = PDO_PLACEHOLDER_POSITIONAL; dbh->max_escaped_char_length = 2; ret = 1; |