outsourced the generation of where, order, acl check, search in the
datatable to a new function. This function can now be used outside of
the datatable module. So you are able to write complex query and use the
benefits of the datatable module (where clause building, with acl_check)

Function datatable_get_SQLSuffix() {
return array(
			'WHERE' => empty($sWhere) ? '' : $sWhere,
			'ORDER' => empty($sOrder) ? '' : $sOrder ,
			'JOINS' => empty($sJoins) ? '' : $sJoins,
			'GROUP' => empty($sGroupBy) ? '' : $sGroupBy ,
			'LIMIT' => $pagesize,
			'OFFSET' => $offset,
			'PAGENR' => $pageNumber 
			); 
}