I was having problems using queries with GROUP BY so I modified _ajaxtable_render() so now it works. I have modified ajaxtable.module:263 so it now looks like this:

    if ($search_query) {
      $search_query =  ' (' . $search_query . ') ';
      if (strpos($table['query'],'WHERE') > 0) {
        $connect = ' AND ';
      } else {
        $connect = ' WHERE ';
      }
      if (strpos($table['query'], "GROUP BY")) {
        $table['query'] = str_replace('GROUP BY ', $connect . $search_query.' GROUP BY ', $table['query']);
      }else {
        if (strpos($table['query'], "HAVING")) {
          $table['query'] = str_replace('HAVING ', $connect . $search_query.' HAVING ', $table['query']);
        }else {
          if (strpos($table['query'], "ORDER BY")) {
            $table['query'] = str_replace('ORDER BY ', $connect . $search_query.' ORDER BY ', $table['query']);
        
          } else {
            $table['query'] .= $connect . $search_query;
          }
        }
      }
    }

It should also work with queries using HAVING; but I haven't tested it.

How could this changes make it to the module? I am doing other modifications to the module which I think can be useful to other developers.

Comments

ArvindSingh’s picture

Check with Stompeers. There is support request titled ' Any maintainers for Ajaxtable?' and Stompeers is looking for co-maintainers.

Meanwhile, since i'm using Ajaxtable in active development. I'll evaluate some of the fixes you have submitted.

Cheers