From 0c68a7b0e6362c2fad4a4fc9995b91e43bdd4873 Mon Sep 17 00:00:00 2001 From: Tim Otte Date: Tue, 10 Sep 2019 09:11:31 +0200 Subject: [PATCH] Possible solution for the problem "SELECT * is forbidden by SQL rules" --- htdocs/core/class/commondocgenerator.class.php | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/htdocs/core/class/commondocgenerator.class.php b/htdocs/core/class/commondocgenerator.class.php index 28b1dc9d4c1..1b0a9df9a92 100644 --- a/htdocs/core/class/commondocgenerator.class.php +++ b/htdocs/core/class/commondocgenerator.class.php @@ -590,10 +590,15 @@ abstract class CommonDocGenerator $resarray = $this->fill_substitutionarray_with_extrafields($line, $resarray, $extrafields, $array_key, $outputlangs); // Add the product supplier extrafields to the substitutions - $resql = $this->db->query("SELECT * FROM " . MAIN_DB_PREFIX . "product_fournisseur_price_extrafields AS ex INNER JOIN " . MAIN_DB_PREFIX . "product_fournisseur_price AS f ON ex.fk_object = f.rowid WHERE f.ref_fourn = " . $line->ref_fourn); + $extralabels=$extrafields->fetch_name_optionals_label("product_fournisseur_price"); + $columns = ""; + foreach ($extralabels as $key => $value) { + $columns .= "$key, "; + } + substr($columns, 0, strlen($columns) - 2); + $resql = $this->db->query("SELECT $columns FROM " . MAIN_DB_PREFIX . "product_fournisseur_price_extrafields AS ex INNER JOIN " . MAIN_DB_PREFIX . "product_fournisseur_price AS f ON ex.fk_object = f.rowid WHERE f.ref_fourn = " . $line->ref_fourn); if ($this->db->num_rows($resql) > 0) { $resql = $this->db->fetch_object($resql); - $extralabels=$extrafields->fetch_name_optionals_label("product_fournisseur_price"); foreach ($extralabels as $key => $value) { $resarray['line_product_supplier_'.$key] = $resql->{$key}; }