Quantcast
Channel: WordPress › Support » Forum: Hacks - Recent Topics
Viewing all articles
Browse latest Browse all 8245

briancostea on "$wpdb->get_results returns empty array if called more than once"

$
0
0

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 all articles
Browse latest Browse all 8245

Trending Articles