Allyta Posted May 6, 2021 Share Posted May 6, 2021 (edited) Bonjour, J'aimerais afficher les infos de 3 tables dans mon formulaire mais mon premier INNER JOIN se fait ré-écrire par mon second INNER JOIN. Conclusion : seules les infos de la table principale (reception) et du second INNER JOIN (avec la table fournisseur) s'affichent. Y-a-t-il une solution rapide et propre pour corriger ce problème ou est-ce qu'il vaut mieux changer la forme de mon JOIN avec un SELECT x FROM a WHERE b ? public function __construct(){ $this->bootstrap = true; //Gestion de l'affichage en mode bootstrap $this->table = 'gp_reception'; //Table de l'objet $this->identifier = 'id_reception'; //Clé primaire de l'objet $this->className = Reception::class; //Classe de l'objet $this->lang = false; //Flag pour dire si utilisation de langues ou non $this->_join = 'INNER JOIN '._DB_PREFIX_. 'GP_' . 'ingredient i ON (a.id_ingredient = i.id_ingredient)'; $this->_select = 'i.nom_ingredient AS `ingredient_reception`'; $this->_join = 'INNER JOIN '._DB_PREFIX_. 'GP_' . 'fournisseur f ON (a.id_fournisseur = f.id_fournisseur)'; $this->_select = 'f.nom_fournisseur AS `fournisseur_reception`'; //Liste des champs de l'objet à afficher dans la liste $this->fields_list = array( 'date_reception' => array('title' => 'Date', 'width' => 'auto'), 'ingredient_reception' => array('title' => 'Ingrédient', 'width' => 'auto'), 'fournisseur_reception' => array('title' => 'Fournisseur', 'width' => 'auto'), 'ingredient_quantite_reception' => array('title' => 'Quantité', 'width' => 'auto'), 'num_lot_fournisseur_reception' => array('title' => 'Num lot fournisseur', 'width' => 'auto'), 'num_lot_reception' => array('title' => 'Num lot', 'width' => 'auto'), 'quantite_conforme_reception' => array('title' => 'Conformité', 'width' => 'auto'), 'integrite_reception' => array('title' => 'Intégrité', 'width' => 'auto'), ); //Ajout d'actions sur chaque ligne //$this->addRowAction('view'); $this->addRowAction('edit'); $this->addRowAction('delete'); parent::__construct(); } Merci 😃 Edited May 7, 2021 by Allyta (see edit history) Link to comment Share on other sites More sharing options...
doekia Posted May 6, 2021 Share Posted May 6, 2021 (edited) Utiliser la concaténation $this->_join += ' INNER JOIN ... Edited May 6, 2021 by doekia (see edit history) Link to comment Share on other sites More sharing options...
Allyta Posted May 6, 2021 Author Share Posted May 6, 2021 Je ne comprends pas bien ^-^ll Est-ce que tu pourrais mettre un exemple s'il-te-plait ? Link to comment Share on other sites More sharing options...
doekia Posted May 6, 2021 Share Posted May 6, 2021 += (désolé mon 1ere post non corrigé avait une coquille) et l'espace aussi Link to comment Share on other sites More sharing options...
Allyta Posted May 6, 2021 Author Share Posted May 6, 2021 Pas de souci ^-^ J'ai essayé $this->_join = 'INNER JOIN '._DB_PREFIX_. 'GP_' . 'ingredient i ON (a.id_ingredient = i.id_ingredient)'; $this->_select = 'i.nom_ingredient AS `ingredient_reception`'; $this->_join += 'INNER JOIN '._DB_PREFIX_. 'GP_' . 'fournisseur f ON (a.id_fournisseur = f.id_fournisseur)'; $this->_select += 'f.nom_fournisseur AS `fournisseur_reception`'; et $this->_join += 'INNER JOIN '._DB_PREFIX_. 'GP_' . 'ingredient i ON (a.id_ingredient = i.id_ingredient)'; $this->_select += 'i.nom_ingredient AS `ingredient_reception`'; $this->_join += 'INNER JOIN '._DB_PREFIX_. 'GP_' . 'fournisseur f ON (a.id_fournisseur = f.id_fournisseur)'; $this->_select += 'f.nom_fournisseur AS `fournisseur_reception`'; mais sans succès. Erreur : Warning: A non-numeric value encountered au niveau du += Je dois mal m'y prendre pour appliquer ta consigne. Link to comment Share on other sites More sharing options...
doekia Posted May 6, 2021 Share Posted May 6, 2021 Excuses j'ai passé la journée en javascript ... la syntaxe php est .= et ... mets un ESPACE entre l'apostrophe et INNER ' INNER ' Link to comment Share on other sites More sharing options...
Allyta Posted May 7, 2021 Author Share Posted May 7, 2021 (edited) C'est rien 😃 J'ai tenté ça mais j'ai une erreur de syntaxe pourtant mes INNER JOIN fonctionnent bien individuellement. (J'ai mis l'espace aussi ) $this->_join .= ' INNER JOIN '._DB_PREFIX_. 'GP_' . 'ingredient i ON (a.id_ingredient = i.id_ingredient)'; $this->_select .= 'i.nom_ingredient AS `ingredient_reception`'; $this->_join .= ' INNER JOIN '._DB_PREFIX_. 'GP_' . 'fournisseur f ON (a.id_fournisseur = f.id_fournisseur)'; $this->_select .= 'f.nom_fournisseur AS `fournisseur_reception`'; //Liste des champs de l'objet à afficher dans la liste $this->fields_list = array( 'date_reception' => array('title' => 'Date', 'width' => 'auto'), 'ingredient_reception' => array('title' => 'Ingrédient', 'width' => 'auto'), 'fournisseur_reception' => array('title' => 'Fournisseur', 'width' => 'auto'), 'ingredient_quantite_reception' => array('title' => 'Quantité', 'width' => 'auto'), 'num_lot_fournisseur_reception' => array('title' => 'Num lot fournisseur', 'width' => 'auto'), 'num_lot_reception' => array('title' => 'Num lot', 'width' => 'auto'), 'quantite_conforme_reception' => array('title' => 'Conformité', 'width' => 'auto'), 'integrite_reception' => array('title' => 'Intégrité', 'width' => 'auto'), ); Il faut adapter le fields_list pour qu'il arrive à sortir les valeurs de la concaténation ? Edited May 7, 2021 by Allyta (see edit history) Link to comment Share on other sites More sharing options...
doekia Posted May 7, 2021 Share Posted May 7, 2021 Comme l'erreur SQL le mentionne ton erreur de syntaxe vient des SELECT, il faut des , pour séparer les champs ajoutés 1 Link to comment Share on other sites More sharing options...
Allyta Posted May 7, 2021 Author Share Posted May 7, 2021 Bien vu 😃 Tous s'affiche parfaitement maintenant. Merci beaucoup ! Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now