$query = "CALL .........."; 
$result = $wpdb->get_results($query); 

Is returning an empty array and $wpdb->query does not return anything, how do you run stored procedures from the $wpdb class?

  • It would be great if you could make the query more detailed (just add some example data). Is $wpdb->query() returning NULL or something else in your case? As Denis wrote, this might be something that needs to be reported in WP Trac, so any additional information might be useful. – hakre Nov 10 '10 at 14:31

wpdb detects the type of query and returns the result if it starts with select, else the affected rows. Since yours starts by call, it's probably mistaking it for an insert, update, delete, etc. statement.

Try this (might trick wpdb into thinking it's a select statement:

/* select */ call ...;

Or this (not sure the mysql parser will like it):

select * from ( call ... );

If all else fails (and even if not), consider opening a ticket in the wp trac.


I am not sure about procedures, but good start will be to check if there is some reason reported for query failing.

You can turn error echoing on and off with the show_errors and hide_errors, respectively.

<?php $wpdb->show_errors(); ?>

<?php $wpdb->hide_errors(); ?>

You can also print the error (if any) generated by the most recent query with print_error.

<?php $wpdb->print_error(); ?>

Function Reference/wpdb Class > Show and Hide SQL errors

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy