unit uDBPagination;

{< DB pagination for mySQL - adding LIMIT M,N phrase to Select Request}

interface

uses
  System.SysUtils, System.Classes, FireDAC.Stan.Intf, FireDAC.Stan.Option, FireDAC.Stan.Param, FireDAC.Stan.Error,
  FireDAC.DatS, FireDAC.Phys.Intf, FireDAC.DApt.Intf, FireDAC.Stan.Async, FireDAC.DApt, Data.DB, FireDAC.Comp.DataSet,
  FireDAC.Comp.Client;

type
  TDBPagination = class(TDataModule)
  private

   FFDQuery:TFDQuery;
   FSQLRequest:string;

   FCurrentRow:Int64;

   FStartRow:Int64;
   FRowCountToLoad:Int64;



  public
    { Public declarations }

    procedure InitialUpdate();
    procedure Next(AStartRow,ANumberOfRowsToLoad:Int64);
    procedure Previous(AStartRow,ANumberOfRowsToLoad:Int64);

    property FDQuery:TFDQuery read FFDQuery write FFDQuery;
    property SQLRequest:string read FSQLRequest write FSQLRequest;


    property  StartRow:Int64 read FStartRow write FStartRow;
    property  RowCountToLoad:Int64 read FRowCountToLoad write FRowCountToLoad;




  end;


//var
//  DBPagination: TDBPagination;

implementation

{%CLASSGROUP 'Vcl.Controls.TControl'}

{$R *.dfm}

{ TDBPagination }

procedure TDBPagination.InitialUpdate;

var SQLTextTemp:String;

begin

if Assigned(FDQuery) then

 begin

    FDQuery.Disconnect();

    FDQuery.Close();

    with FDQuery do begin

    Params.ParamValues['M']:=0;
    Params.ParamValues['N']:=7;


    end;



    FDQuery.Open();

 end;



end;

procedure TDBPagination.Next(AStartRow, ANumberOfRowsToLoad: Int64);
begin

end;

procedure TDBPagination.Previous(AStartRow, ANumberOfRowsToLoad: Int64);
begin

end;

end.
