@@ -154,6 +154,32 @@ static int pdo_mysql_fill_stmt_from_result(pdo_stmt_t *stmt) /* {{{ */
154
154
}
155
155
/* }}} */
156
156
157
+ static bool pdo_mysql_stmt_after_execute_prepared (pdo_stmt_t * stmt ) {
158
+ pdo_mysql_stmt * S = stmt -> driver_data ;
159
+ pdo_mysql_db_handle * H = S -> H ;
160
+
161
+ /* For SHOW/DESCRIBE and others the column/field count is not available before execute. */
162
+ php_pdo_stmt_set_column_count (stmt , mysql_stmt_field_count (S -> stmt ));
163
+ for (int i = 0 ; i < stmt -> column_count ; i ++ ) {
164
+ mysqlnd_stmt_bind_one_result (S -> stmt , i );
165
+ }
166
+
167
+ S -> result = mysqlnd_stmt_result_metadata (S -> stmt );
168
+ if (S -> result ) {
169
+ S -> fields = mysql_fetch_fields (S -> result );
170
+ /* If buffered, pre-fetch all the data */
171
+ if (H -> buffered ) {
172
+ if (mysql_stmt_store_result (S -> stmt )) {
173
+ pdo_mysql_error_stmt (stmt );
174
+ return false;
175
+ }
176
+ }
177
+ }
178
+
179
+ pdo_mysql_stmt_set_row_count (stmt );
180
+ return true;
181
+ }
182
+
157
183
#ifndef PDO_USE_MYSQLND
158
184
static int pdo_mysql_stmt_execute_prepared_libmysql (pdo_stmt_t * stmt ) /* {{{ */
159
185
{
@@ -272,8 +298,6 @@ static int pdo_mysql_stmt_execute_prepared_libmysql(pdo_stmt_t *stmt) /* {{{ */
272
298
static int pdo_mysql_stmt_execute_prepared_mysqlnd (pdo_stmt_t * stmt ) /* {{{ */
273
299
{
274
300
pdo_mysql_stmt * S = stmt -> driver_data ;
275
- pdo_mysql_db_handle * H = S -> H ;
276
- int i ;
277
301
278
302
PDO_DBG_ENTER ("pdo_mysql_stmt_execute_prepared_mysqlnd" );
279
303
@@ -288,26 +312,7 @@ static int pdo_mysql_stmt_execute_prepared_mysqlnd(pdo_stmt_t *stmt) /* {{{ */
288
312
S -> result = NULL ;
289
313
}
290
314
291
- /* for SHOW/DESCRIBE and others the column/field count is not available before execute */
292
- php_pdo_stmt_set_column_count (stmt , mysql_stmt_field_count (S -> stmt ));
293
- for (i = 0 ; i < stmt -> column_count ; i ++ ) {
294
- mysqlnd_stmt_bind_one_result (S -> stmt , i );
295
- }
296
-
297
- S -> result = mysqlnd_stmt_result_metadata (S -> stmt );
298
- if (S -> result ) {
299
- S -> fields = mysql_fetch_fields (S -> result );
300
- /* if buffered, pre-fetch all the data */
301
- if (H -> buffered ) {
302
- if (mysql_stmt_store_result (S -> stmt )) {
303
- pdo_mysql_error_stmt (stmt );
304
- PDO_DBG_RETURN (0 );
305
- }
306
- }
307
- }
308
-
309
- pdo_mysql_stmt_set_row_count (stmt );
310
- PDO_DBG_RETURN (1 );
315
+ PDO_DBG_RETURN (pdo_mysql_stmt_after_execute_prepared (stmt ));
311
316
}
312
317
/* }}} */
313
318
#endif
@@ -364,30 +369,7 @@ static int pdo_mysql_stmt_next_rowset(pdo_stmt_t *stmt) /* {{{ */
364
369
PDO_DBG_RETURN (0 );
365
370
}
366
371
367
- {
368
- /* for SHOW/DESCRIBE and others the column/field count is not available before execute */
369
- int i ;
370
-
371
- php_pdo_stmt_set_column_count (stmt , mysql_stmt_field_count (S -> stmt ));
372
- for (i = 0 ; i < stmt -> column_count ; i ++ ) {
373
- mysqlnd_stmt_bind_one_result (S -> stmt , i );
374
- }
375
- }
376
-
377
- S -> result = mysqlnd_stmt_result_metadata (S -> stmt );
378
- if (S -> result ) {
379
- S -> fields = mysql_fetch_fields (S -> result );
380
-
381
- /* if buffered, pre-fetch all the data */
382
- if (H -> buffered ) {
383
- if (mysql_stmt_store_result (S -> stmt )) {
384
- pdo_mysql_error_stmt (stmt );
385
- PDO_DBG_RETURN (0 );
386
- }
387
- }
388
- }
389
- pdo_mysql_stmt_set_row_count (stmt );
390
- PDO_DBG_RETURN (1 );
372
+ PDO_DBG_RETURN (pdo_mysql_stmt_after_execute_prepared (stmt ));
391
373
}
392
374
#endif
393
375
0 commit comments