mirror of
https://github.com/php/php-src.git
synced 2025-08-16 05:58:45 +02:00
Experimental support for queries returning multiple rowsets under mysql 5.0.
Patch from Guy Harrison (guy dot a dot harrison (at) gmail dot com)
This commit is contained in:
parent
6fd9e5a64f
commit
1bbab25455
3 changed files with 55 additions and 4 deletions
|
@ -58,7 +58,7 @@ Note that the MySQL client library is not bundled anymore!])
|
|||
|
||||
_SAVE_LDFLAGS=$LDFLAGS
|
||||
LDFLAGS="$LDFLAGS $PDO_MYSQL_LIBS"
|
||||
AC_CHECK_FUNCS([mysql_commit mysql_stmt_prepare])
|
||||
AC_CHECK_FUNCS([mysql_commit mysql_stmt_prepare mysql_next_result])
|
||||
LDFLAGS=$_SAVE_LDFLAGS
|
||||
|
||||
PHP_CHECK_PDO_INCLUDES
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
+----------------------------------------------------------------------+
|
||||
| PHP Version 5 |
|
||||
+----------------------------------------------------------------------+
|
||||
| Copyright (c) 1997-2004 The PHP Group |
|
||||
| Copyright (c) 1997-2005 The PHP Group |
|
||||
+----------------------------------------------------------------------+
|
||||
| This source file is subject to version 3.0 of the PHP license, |
|
||||
| that is bundled with this package in the file LICENSE, and is |
|
||||
|
@ -305,6 +305,14 @@ static int pdo_mysql_handle_factory(pdo_dbh_t *dbh, zval *driver_options TSRMLS_
|
|||
{ "port", "3306", 0 },
|
||||
{ "unix_socket", PDO_MYSQL_UNIX_ADDR, 0 },
|
||||
};
|
||||
int connect_opts = 0
|
||||
#ifdef CLIENT_MULTI_RESULTS
|
||||
|CLIENT_MULTI_RESULTS
|
||||
#endif
|
||||
#ifdef CLIENT_MULTI_STATEMENTS
|
||||
|CLIENT_MULTI_STATEMENTS
|
||||
#endif
|
||||
;
|
||||
|
||||
php_pdo_parse_data_source(dbh->data_source, dbh->data_source_len, vars, 4);
|
||||
|
||||
|
@ -337,7 +345,7 @@ static int pdo_mysql_handle_factory(pdo_dbh_t *dbh, zval *driver_options TSRMLS_
|
|||
port = atoi(vars[3].optval);
|
||||
}
|
||||
dbname = vars[1].optval;
|
||||
if (mysql_real_connect(H->server, host, dbh->username, dbh->password, dbname, port, unix_socket, 0) == NULL) {
|
||||
if (mysql_real_connect(H->server, host, dbh->username, dbh->password, dbname, port, unix_socket, connect_opts) == NULL) {
|
||||
pdo_mysql_error(dbh);
|
||||
goto cleanup;
|
||||
}
|
||||
|
|
|
@ -93,6 +93,46 @@ static int pdo_mysql_stmt_execute(pdo_stmt_t *stmt TSRMLS_DC)
|
|||
return 1;
|
||||
}
|
||||
|
||||
#if HAVE_MYSQL_NEXT_RESULT
|
||||
static int pdo_mysql_stmt_next_rowset(pdo_stmt_t *stmt TSRMLS_DC)
|
||||
{
|
||||
pdo_mysql_stmt *S = (pdo_mysql_stmt*)stmt->driver_data;
|
||||
pdo_mysql_db_handle *H = S->H;
|
||||
my_ulonglong row_count;
|
||||
int debug=0;
|
||||
int ret;
|
||||
|
||||
/* ensure that we free any previous unfetched results */
|
||||
if (S->result) {
|
||||
mysql_free_result(S->result);
|
||||
S->result = NULL;
|
||||
}
|
||||
|
||||
ret = mysql_next_result(H->server);
|
||||
|
||||
if (ret > 0) {
|
||||
pdo_mysql_error_stmt(stmt);
|
||||
return 0;
|
||||
} else if (ret < 0) {
|
||||
/* No more results */
|
||||
return 0;
|
||||
} else {
|
||||
row_count = mysql_affected_rows(H->server);
|
||||
S->result = mysql_use_result(H->server);
|
||||
|
||||
if (NULL == S->result) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
stmt->row_count = row_count;
|
||||
stmt->column_count = (int) mysql_num_fields(S->result);
|
||||
S->fields = mysql_fetch_fields(S->result);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
static int pdo_mysql_stmt_param_hook(pdo_stmt_t *stmt, struct pdo_bound_param_data *param,
|
||||
enum pdo_param_event event_type TSRMLS_DC)
|
||||
{
|
||||
|
@ -256,7 +296,10 @@ struct pdo_stmt_methods mysql_stmt_methods = {
|
|||
pdo_mysql_stmt_param_hook,
|
||||
NULL, /* set_attr */
|
||||
NULL, /* get_attr */
|
||||
pdo_mysql_stmt_col_meta
|
||||
pdo_mysql_stmt_col_meta,
|
||||
#if HAVE_MYSQL_NEXT_RESULT
|
||||
pdo_mysql_stmt_next_rowset
|
||||
#endif
|
||||
};
|
||||
|
||||
/*
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue