Jump to content

[Résolu] Plusieurs INNER JOIN pour un formulaire


Recommended Posts

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 😃

1.JPG

Edited by Allyta (see edit history)
Link to comment
Share on other sites

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

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 ?
 

1.JPG

Edited by Allyta (see edit history)
Link to comment
Share on other sites

  • Allyta changed the title to [Résolu] Plusieurs INNER JOIN pour un formulaire

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...