Index: customreports.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/customreports/customreports.module,v
retrieving revision 1.4.2.4.2.4
diff -u -p -r1.4.2.4.2.4 customreports.module
--- customreports.module	17 Nov 2010 12:58:41 -0000	1.4.2.4.2.4
+++ customreports.module	22 Feb 2011 11:07:30 -0000
@@ -186,10 +186,22 @@ function customreports_render($type, $no
   if($custom_db) {
     db_set_active($matches[1]);
     $node->body = str_replace($matches[0], '', $node->body);
+    $result = db_query($node->body, $args);
+  }
+  else {
+    // Pressflow users can use the slave db for these queries, read more on the
+    // following link.
+    // https://wiki.fourkitchens.com/display/PF/Using+database+replication+with+Pressflow+5+and+6
+    // Allow parameters to be passed as arguments.
+    if (function_exists('db_query_slave')) {
+      // As we have a slave db.
+      $result = db_query_slave($node->body, $args);
+    }
+    else {
+      // We are on a normal instalation of drupal.
+      $result = db_query($node->body, $args);
+    }
   }
-
-  // Allow parameters to be passed as arguments.
-  $result = db_query($node->body, $args);
 
   if($custom_db) {
     db_set_active();
@@ -279,4 +291,4 @@ function customreports_render_xls($heade
 
 function _clean_quotes(&$item, $key) {
   $item = str_replace('"', "'", $item);
-}
\ No newline at end of file
+}
