Today I was get stuck while calling stored procedure in wordpress. Neither $wpdb->get_results nor $wpdb->get_results was working. I got the point somrthing was went wrong. The output of $wpdb->show_errors() is nothing so there was not an error.
This is a create statement of my procedure I’m tried to called it using $wpdb
CREATE PROCEDURE posts_count(OUT @total_posts INT) BEGIN SELECT COUNT(*) INTO total_posts FROM wp_posts; END//
Okay so I get to knew while try and test try and test
$result = $wpdb->query("CALL posts_count(@total_posts)"); $result = $wpdb->get_results("SELECT @total_posts"); var_dump( $result );
So finally it working. It is returning me a correct output
array (size=1) 0 => object(stdClass) public '@total_posts' => string '19' (length=2)