Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.
$query = "CALL .........."; 
$result = $wpdb->get_results($query); 
print_r($results);

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

share|improve this question
    
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
add comment

2 Answers

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.

share|improve this answer
add comment

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

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.