File tree Expand file tree Collapse file tree 4 files changed +868
-6
lines changed
Expand file tree Collapse file tree 4 files changed +868
-6
lines changed Original file line number Diff line number Diff line change @@ -93,6 +93,15 @@ public function
9393 return static ::$ CTX [$ Alias ];
9494 }
9595
96+ public function
97+ GetDatabaseType (string $ Alias ):
98+ string {
99+
100+ $ DB = $ this ->Get ($ Alias );
101+
102+ return $ DB ->Type ;
103+ }
104+
96105 ////////////////////////////////////////////////////////////////
97106 ////////////////////////////////////////////////////////////////
98107
Original file line number Diff line number Diff line change @@ -595,12 +595,36 @@ static public function
595595 //Common\Dump::Var($SQL, TRUE);
596596
597597 $ Result = $ SQL ->Query ($ Opt ->GetData ());
598- $ Output ->Total = (
599- ($ SQL ->GetDatabase ())
600- ->Query ('SELECT FOUND_ROWS() AS Total; ' )
601- ->Next ()
602- ->Total
603- );
598+
599+ ////////
600+
601+ // mysql can find pagination totals with its extra flags and
602+ // special query. other databases like sqlite need to do a second
603+ // unrestrained query.
604+
605+ if ($ DBM ->GetDatabaseType (static ::$ DBA ) === 'mysql ' ) {
606+ $ Output ->Total = (
607+ ($ SQL ->GetDatabase ())
608+ ->Query ('SELECT FOUND_ROWS() AS Total; ' )
609+ ->Next ()
610+ ->Total
611+ );
612+ }
613+
614+ else {
615+ $ SQL ->Fields ('COUNT(*) AS Total ' , TRUE );
616+ $ SQL ->Limit (0 );
617+ $ SQL ->Offset (0 );
618+
619+ $ Output ->Total = (
620+ ($ SQL )
621+ ->Query ($ Opt ->GetData ())
622+ ->Next ()
623+ ->Total
624+ );
625+ }
626+
627+ ////////
604628
605629 $ RowClassName = static ::class;
606630
Original file line number Diff line number Diff line change @@ -894,6 +894,9 @@ protected function
894894 // todo 2022-12-18
895895 // it needs to determine this from the connection type.
896896
897+ if ($ this ->Database ->Type === 'sqlite ' )
898+ return 'Nether \\Database \\Verse \\SQLite ' ;
899+
897900 return 'Nether \\Database \\Verse \\MySQL ' ;
898901 }
899902
You can’t perform that action at this time.
0 commit comments