mirror of
https://github.com/Dolibarr/dolibarr.git
synced 2026-02-07 16:41:48 +01:00
FIX: more correctly parse the select part to be replaced in sql queries
This commit is contained in:
@@ -563,7 +563,7 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) {
|
||||
$nbtotalofrecords++;
|
||||
}*/
|
||||
/* The fast and low memory method to get and count full list converts the sql into a sql count */
|
||||
$sqlforcount = preg_replace('/^SELECT[a-z0-9\._\s\(\),]+FROM/i', 'SELECT COUNT(*) as nbtotalofrecords FROM', $sql);
|
||||
$sqlforcount = preg_replace('/^SELECT[a-z0-9\._\s\(\),=<>\:\-\'\+\*\/"`]+\sFROM/Ui', 'SELECT COUNT(*) as nbtotalofrecords FROM', $sql);
|
||||
$resql = $db->query($sqlforcount);
|
||||
$objforcount = $db->fetch_object($resql);
|
||||
$nbtotalofrecords = $objforcount->nbtotalofrecords;
|
||||
|
||||
@@ -851,9 +851,9 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) {
|
||||
*/
|
||||
/* The fast and low memory method to get and count full list converts the sql into a sql count */
|
||||
if ($sall || $search_product_category > 0 || $search_user > 0) {
|
||||
$sqlforcount = preg_replace('/^SELECT[a-zA-Z0-9\._\s\(\),=<>\:\-\']+\sFROM/', 'SELECT COUNT(DISTINCT f.rowid) as nbtotalofrecords FROM', $sql);
|
||||
$sqlforcount = preg_replace('/^SELECT[a-z0-9\._\s\(\),=<>\:\-\'\+\*\/"`]+\sFROM/Ui', 'SELECT COUNT(DISTINCT f.rowid) as nbtotalofrecords FROM', $sql);
|
||||
} else {
|
||||
$sqlforcount = preg_replace('/^SELECT[a-zA-Z0-9\._\s\(\),=<>\:\-\']+\sFROM/', 'SELECT COUNT(f.rowid) as nbtotalofrecords FROM', $sql);
|
||||
$sqlforcount = preg_replace('/^SELECT[a-z0-9\._\s\(\),=<>\:\-\'\+\*\/"`]+\sFROM/Ui', 'SELECT COUNT(f.rowid) as nbtotalofrecords FROM', $sql);
|
||||
$sqlforcount = preg_replace('/LEFT JOIN '.MAIN_DB_PREFIX.'paiement_facture as pf ON pf.fk_facture = f.rowid/', '', $sqlforcount);
|
||||
}
|
||||
$sqlforcount = preg_replace('/GROUP BY.*$/', '', $sqlforcount);
|
||||
|
||||
@@ -369,7 +369,7 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) {
|
||||
$nbtotalofrecords++;
|
||||
}*/
|
||||
/* The fast and low memory method to get and count full list converts the sql into a sql count */
|
||||
$sqlforcount = preg_replace('/^SELECT[a-z0-9\._\s\(\),]+FROM/i', 'SELECT COUNT(*) as nbtotalofrecords FROM', $sql);
|
||||
$sqlforcount = preg_replace('/^SELECT[a-z0-9\._\s\(\),=<>\:\-\'\+\*\/"`]+\sFROM/Ui', 'SELECT COUNT(*) as nbtotalofrecords FROM', $sql);
|
||||
$resql = $db->query($sqlforcount);
|
||||
$objforcount = $db->fetch_object($resql);
|
||||
$nbtotalofrecords = $objforcount->nbtotalofrecords;
|
||||
|
||||
@@ -585,7 +585,7 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) {
|
||||
$nbtotalofrecords++;
|
||||
}*/
|
||||
/* The fast and low memory method to get and count full list converts the sql into a sql count */
|
||||
$sqlforcount = preg_replace('/^SELECT[a-z0-9\._\s\(\),]+FROM/i', 'SELECT COUNT(*) as nbtotalofrecords FROM', $sql);
|
||||
$sqlforcount = preg_replace('/^SELECT[a-z0-9\._\s\(\),=<>\:\-\'\+\*\/"`]+\sFROM/Ui', 'SELECT COUNT(*) as nbtotalofrecords FROM', $sql);
|
||||
$resql = $db->query($sqlforcount);
|
||||
$objforcount = $db->fetch_object($resql);
|
||||
$nbtotalofrecords = $objforcount->nbtotalofrecords;
|
||||
|
||||
@@ -294,7 +294,7 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) {
|
||||
$nbtotalofrecords++;
|
||||
}*/
|
||||
/* The fast and low memory method to get and count full list converts the sql into a sql count */
|
||||
$sqlforcount = preg_replace('/^SELECT[a-z0-9\._\s\(\),]+FROM/i', 'SELECT COUNT(*) as nbtotalofrecords FROM', $sql);
|
||||
$sqlforcount = preg_replace('/^SELECT[a-z0-9\._\s\(\),=<>\:\-\'\+\*\/"`]+\sFROM/Ui', 'SELECT COUNT(*) as nbtotalofrecords FROM', $sql);
|
||||
$resql = $db->query($sqlforcount);
|
||||
$objforcount = $db->fetch_object($resql);
|
||||
$nbtotalofrecords = $objforcount->nbtotalofrecords;
|
||||
|
||||
@@ -454,7 +454,7 @@ $sql .= $hookmanager->resPrint;
|
||||
$nbtotalofrecords = '';
|
||||
if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) {
|
||||
/* The fast and low memory method to get and count full list converts the sql into a sql count */
|
||||
$sqlforcount = preg_replace('/^SELECT[a-z0-9\._\s\(\),]+FROM/i', 'SELECT COUNT(*) as nbtotalofrecords FROM', $sql);
|
||||
$sqlforcount = preg_replace('/^SELECT[a-z0-9\._\s\(\),=<>\:\-\'\+\*\/"`]+\sFROM/Ui', 'SELECT COUNT(*) as nbtotalofrecords FROM', $sql);
|
||||
$resql = $db->query($sqlforcount);
|
||||
$objforcount = $db->fetch_object($resql);
|
||||
$nbtotalofrecords = $objforcount->nbtotalofrecords;
|
||||
|
||||
Reference in New Issue
Block a user