| @@ -56,12 +56,14 @@ | ||
| 56 | 56 | /** |
| 57 | 57 | * Fetches information from source, parses it and builds series and data arrays. |
| 58 | 58 | * |
| 59 | 59 | * @param bool $as_html Should the result be fetched as an HTML table or as an object. |
| 60 | + * @param bool $results_as_numeric_array Should the result be fetched as ARRAY_N instead of ARRAY_A. | |
| 61 | + * @param bool $raw_results Should the result be returned without processing. | |
| 60 | 62 | * @access public |
| 61 | 63 | * @return boolean TRUE on success, otherwise FALSE. |
| 62 | 64 | */ |
| 63 | - public function fetch( $as_html = false ) { | |
| 65 | + public function fetch( $as_html = false, $results_as_numeric_array = false, $raw_results = false ) { | |
| 64 | 66 | if ( empty( $this->_query ) ) { |
| 65 | 67 | return false; |
| 66 | 68 | } |
| 67 | 69 | |
| @@ -66,17 +68,22 @@ | ||
| 66 | 68 | } |
| 67 | 69 | |
| 68 | 70 | // impose a limit if no limit clause is provided. |
| 69 | 71 | if ( strpos( strtolower( $this->_query ), ' limit ' ) === false ) { |
| 70 | - $this->_query .= ' LIMIT ' . apply_filters( 'visualizer_sql_query_limit', 300 ); | |
| 72 | + $this->_query .= ' LIMIT ' . apply_filters( 'visualizer_sql_query_limit', 1000 ); | |
| 71 | 73 | } |
| 72 | 74 | |
| 73 | 75 | global $wpdb; |
| 74 | 76 | $wpdb->hide_errors(); |
| 75 | 77 | // @codingStandardsIgnoreStart |
| 76 | - $rows = $wpdb->get_results( $this->_query, ARRAY_A ); | |
| 78 | + $rows = $wpdb->get_results( $this->_query, $results_as_numeric_array ? ARRAY_N : ARRAY_A ); | |
| 79 | + do_action( 'themeisle_log_event', Visualizer_Plugin::NAME, sprintf( 'Firing query %s to get results %s with error %s', $this->_query, print_r( $rows, true ), print_r( $wpdb->last_error, true ) ), 'debug', __FILE__, __LINE__ ); | |
| 77 | 80 | // @codingStandardsIgnoreEnd |
| 78 | 81 | $wpdb->show_errors(); |
| 82 | + | |
| 83 | + if ( $raw_results ) { | |
| 84 | + return $rows; | |
| 85 | + } | |
| 79 | 86 | |
| 80 | 87 | if ( $rows ) { |
| 81 | 88 | $results = array(); |
| 82 | 89 | $headers = array(); |