@@ -1386,19 +1386,23 @@ public function getCompiledSelect($reset = true)
13861386 *
13871387 * @param int $limit The limit clause
13881388 * @param int $offset The offset clause
1389- * @param bool $returnSQL If true, returns the generate SQL, otherwise executes the query.
1389+ * @param bool $returnSQL If true, returns the generate SQL, otherwise executes the query.
1390+ * @param bool $reset Are we want to clear query builder values?
13901391 *
13911392 * @return ResultInterface
13921393 */
1393- public function get (int $ limit = null , int $ offset = 0 , $ returnSQL = false )
1394+ public function get (int $ limit = null , int $ offset = 0 , $ returnSQL = false , $ reset = true )
13941395 {
13951396 if ( ! is_null ($ limit ))
13961397 {
13971398 $ this ->limit ($ limit , $ offset );
13981399 }
13991400 $ result = $ returnSQL ? $ this ->getCompiledSelect () : $ this ->db ->query ($ this ->compileSelect (), $ this ->binds );
14001401
1401- $ this ->resetSelect ();
1402+ if ($ reset == true )
1403+ {
1404+ $ this ->resetSelect ();
1405+ }
14021406
14031407 return $ result ;
14041408 }
@@ -1411,11 +1415,12 @@ public function get(int $limit = null, int $offset = 0, $returnSQL = false)
14111415 * Generates a platform-specific query string that counts all records in
14121416 * the specified database
14131417 *
1414- * @param bool $test Are we running automated tests?
1418+ * @param bool $reset Are we want to clear query builder values?
1419+ * @param bool $test Are we running automated tests?
14151420 *
14161421 * @return int
14171422 */
1418- public function countAll ($ test = false )
1423+ public function countAll ($ reset = true , $ test = false )
14191424 {
14201425 $ table = $ this ->QBFrom [0 ];
14211426
@@ -1434,7 +1439,11 @@ public function countAll($test = false)
14341439 }
14351440
14361441 $ query = $ query ->getRow ();
1437- $ this ->resetSelect ();
1442+
1443+ if ($ reset === true )
1444+ {
1445+ $ this ->resetSelect ();
1446+ }
14381447
14391448 return (int ) $ query ->numrows ;
14401449 }
@@ -1457,6 +1466,7 @@ public function countAllResults($reset = true, $test = false)
14571466 // ORDER BY usage is often problematic here (most notably
14581467 // on Microsoft SQL Server) and ultimately unnecessary
14591468 // for selecting COUNT(*) ...
1469+ $ orderby = [];
14601470 if ( ! empty ($ this ->QBOrderBy ))
14611471 {
14621472 $ orderby = $ this ->QBOrderBy ;
@@ -1480,7 +1490,7 @@ public function countAllResults($reset = true, $test = false)
14801490 // If we've previously reset the QBOrderBy values, get them back
14811491 elseif ( ! isset ($ this ->QBOrderBy ))
14821492 {
1483- $ this ->QBOrderBy = $ orderby ;
1493+ $ this ->QBOrderBy = $ orderby??[] ;
14841494 }
14851495
14861496 $ row = (! $ result instanceof ResultInterface)
0 commit comments