$wpdb->get_results returns empty array if called more than once
-
If I call $wpdb->get_results() twice in a row it returns an empty array the second time. I know the SQL is good b/c it is successful.
$totalsdata = $wpdb->get_results( $wpdb->prepare( "call dl_db_totals('%s', '%s', %d);", $startdate, $enddate, $current_user->ID ) ); print_r($totalsdata); $totalsdata = $wpdb->get_results( $wpdb->prepare( "call dl_db_totals('%s', '%s', %d);", $startdate, $enddate, $current_user->ID ) ); print_r($totalsdata);
The first result prints a full array of values, the second prints an empty array (i.e. Array ()).
The context for this when a you need to call $wpdb->get_results() in a shortcode and the author includes more than one shortcode in a post.
Viewing 4 replies - 1 through 4 (of 4 total)
Viewing 4 replies - 1 through 4 (of 4 total)
- The topic ‘$wpdb->get_results returns empty array if called more than once’ is closed to new replies.