lib/builder.js
function buildQuery(requestQuery) {
        var queries = {};
        if (typeof requestQuery !== 'object')
            return queries;
        var searchString = sanitize(_u.isObject(requestQuery.search) ? requestQuery.search.value : '');
        self.oRequestQuery = requestQuery;
        var useStmt = buildSetDatabaseOrSchemaStatement();
        if (useStmt) {
            queries.changeDatabaseOrSchema = useStmt;
        }
        queries.recordsTotal = buildCountStatement(requestQuery);
        if (searchString) {
            queries.recordsFiltered = buildCountStatement(requestQuery);
        }
        var query = buildSelectPartial();
        query += buildWherePartial(requestQuery);
        query += buildGroupByPartial();
        query += buildOrderingPartial(requestQuery);
        query += buildLimitPartial(requestQuery);
        if (self.dbType === 'oracle'){
            var start = parseInt(requestQuery.start, 10);
            var len = parseInt(requestQuery.length, 10);
            if (len >= 0 && start >= 0) {
                query = 'SELECT * FROM (SELECT a.*, ROWNUM rnum FROM (' + query + ') ';
                query += 'a)' + ' WHERE rnum BETWEEN ' + (start + 1) + ' AND ' + (start + len);
            }
        }
        queries.select = query;
        return queries;
    }
function buildQuery(requestQuery) {
        var queries = {};
        if (typeof requestQuery !== 'object')
            return queries;
        var searchString = sanitize(_u.isObject(requestQuery.search) ? requestQuery.search.value : '');
        self.oRequestQuery = requestQuery;
        var useStmt = buildSetDatabaseOrSchemaStatement();
        if (useStmt) {
            queries.changeDatabaseOrSchema = useStmt;
        }
        queries.recordsTotal = buildCountStatement(requestQuery);
        if (searchString) {
            queries.recordsFiltered = buildCountStatement(requestQuery);
        }
        var query = buildSelectPartial();
        query += buildWherePartial(requestQuery);
        query += buildGroupByPartial();
        query += buildOrderingPartial(requestQuery);
        query += buildLimitPartial(requestQuery);
        if (self.dbType === 'oracle'){
            var start = parseInt(requestQuery.start, 10);
            var len = parseInt(requestQuery.length, 10);
            if (len >= 0 && start >= 0) {
                query = 'SELECT * FROM (SELECT a.*, ROWNUM rnum FROM (' + query + ') ';
                query += 'a)' + ' WHERE rnum BETWEEN ' + (start + 1) + ' AND ' + (start + len);
            }
        }
        queries.select = query;
        return queries;
    }
function buildQuery ( requestQuery ) { var queries = { } ; if ( typeof requestQuery !== 'object' ) return queries ; var searchString = sanitize ( _u . isObject ( requestQuery . search ) ? requestQuery . search . value : '' ) ; self . oRequestQuery = requestQuery ; var useStmt = buildSetDatabaseOrSchemaStatement ( ) ; if ( useStmt ) { queries . changeDatabaseOrSchema = useStmt ; } queries . recordsTotal = buildCountStatement ( requestQuery ) ; if ( searchString ) { queries . recordsFiltered = buildCountStatement ( requestQuery ) ; } var query = buildSelectPartial ( ) ; query += buildWherePartial ( requestQuery ) ; query += buildGroupByPartial ( ) ; query += buildOrderingPartial ( requestQuery ) ; query += buildLimitPartial ( requestQuery ) ; if ( self . dbType === 'oracle' ) { var start = parseInt ( requestQuery . start , 10 ) ; var len = parseInt ( requestQuery . length , 10 ) ; if ( len >= 0 && start >= 0 ) { query = 'SELECT * FROM (SELECT a.*, ROWNUM rnum FROM (' + query + ') ' ; query += 'a)' + ' WHERE rnum BETWEEN ' + ( start + 1 ) + ' AND ' + ( start + len ) ; } } queries . select = query ; return queries ; }
Build an array of query strings based on the Datatable parameters
@param requestQuery The datatable parameters that are generated by the client
@return {Object} An array of query strings, each including a terminating semicolon.
Build an array of query strings based on the Datatable parameters