@@ -131,6 +131,39 @@ static void pdo_mysql_stmt_set_row_count(pdo_stmt_t *stmt TSRMLS_DC) /* {{{ */
131
131
}
132
132
/* }}} */
133
133
134
+ static int pdo_mysql_fill_stmt_from_result (pdo_stmt_t * stmt TSRMLS_DC ) /* {{{ */
135
+ {
136
+ pdo_mysql_stmt * S = (pdo_mysql_stmt * )stmt -> driver_data ;
137
+ pdo_mysql_db_handle * H = S -> H ;
138
+ my_ulonglong row_count ;
139
+ PDO_DBG_ENTER ("pdo_mysql_fill_stmt_from_result" );
140
+
141
+ row_count = mysql_affected_rows (H -> server );
142
+ if (row_count == (my_ulonglong )- 1 ) {
143
+ /* we either have a query that returned a result set or an error occured
144
+ lets see if we have access to a result set */
145
+ if (!H -> buffered ) {
146
+ S -> result = mysql_use_result (H -> server );
147
+ } else {
148
+ S -> result = mysql_store_result (H -> server );
149
+ }
150
+ if (NULL == S -> result ) {
151
+ pdo_mysql_error_stmt (stmt );
152
+ PDO_DBG_RETURN (0 );
153
+ }
154
+
155
+ stmt -> row_count = (long ) mysql_num_rows (S -> result );
156
+ stmt -> column_count = (int ) mysql_num_fields (S -> result );
157
+ S -> fields = mysql_fetch_fields (S -> result );
158
+ } else {
159
+ /* this was a DML or DDL query (INSERT, UPDATE, DELETE, ... */
160
+ stmt -> row_count = (long ) row_count ;
161
+ }
162
+
163
+ PDO_DBG_RETURN (1 );
164
+ }
165
+ /* }}} */
166
+
134
167
#ifdef HAVE_MYSQL_STMT_PREPARE
135
168
static int pdo_mysql_stmt_execute_prepared_libmysql (pdo_stmt_t * stmt TSRMLS_DC ) /* {{{ */
136
169
{
@@ -310,30 +343,7 @@ static int pdo_mysql_stmt_execute(pdo_stmt_t *stmt TSRMLS_DC) /* {{{ */
310
343
PDO_DBG_RETURN (0 );
311
344
}
312
345
313
- row_count = mysql_affected_rows (H -> server );
314
- if (row_count == (my_ulonglong )- 1 ) {
315
- /* we either have a query that returned a result set or an error occured
316
- lets see if we have access to a result set */
317
- if (!H -> buffered ) {
318
- S -> result = mysql_use_result (H -> server );
319
- } else {
320
- S -> result = mysql_store_result (H -> server );
321
- }
322
- if (NULL == S -> result ) {
323
- pdo_mysql_error_stmt (stmt );
324
- PDO_DBG_RETURN (0 );
325
- }
326
-
327
- stmt -> row_count = (long ) mysql_num_rows (S -> result );
328
- stmt -> column_count = (int ) mysql_num_fields (S -> result );
329
- S -> fields = mysql_fetch_fields (S -> result );
330
-
331
- } else {
332
- /* this was a DML or DDL query (INSERT, UPDATE, DELETE, ... */
333
- stmt -> row_count = (long ) row_count ;
334
- }
335
-
336
- PDO_DBG_RETURN (1 );
346
+ PDO_DBG_RETURN (pdo_mysql_fill_stmt_from_result (stmt TSRMLS_CC ));
337
347
}
338
348
/* }}} */
339
349
@@ -421,25 +431,7 @@ static int pdo_mysql_stmt_next_rowset(pdo_stmt_t *stmt TSRMLS_DC) /* {{{ */
421
431
/* No more results */
422
432
PDO_DBG_RETURN (0 );
423
433
} else {
424
- if (!H -> buffered ) {
425
- S -> result = mysql_use_result (H -> server );
426
- row_count = 0 ;
427
- } else {
428
- S -> result = mysql_store_result (H -> server );
429
- if ((long )-1 == (row_count = (long ) mysql_affected_rows (H -> server ))) {
430
- pdo_mysql_error_stmt (stmt );
431
- PDO_DBG_RETURN (0 );
432
- }
433
- }
434
-
435
- if (NULL == S -> result ) {
436
- PDO_DBG_RETURN (0 );
437
- }
438
-
439
- stmt -> row_count = row_count ;
440
- stmt -> column_count = (int ) mysql_num_fields (S -> result );
441
- S -> fields = mysql_fetch_fields (S -> result );
442
- PDO_DBG_RETURN (1 );
434
+ PDO_DBG_RETURN (pdo_mysql_fill_stmt_from_result (stmt TSRMLS_CC ));
443
435
}
444
436
#else
445
437
strcpy (stmt -> error_code , "HYC00" );
0 commit comments