Note that there are some explanatory texts on larger screens.

plurals
  1. POActive record and Joining with specific ID row
    primarykey
    data
    text
    <p>Here my problem :</p> <ul> <li>I have one controller called : events </li> <li>I have one view called : inscrits_liste</li> <li>I have one model called : inscrits_model</li> </ul> <p>I have for my query 2 tables to work on :</p> <p>Table 1 : inscrits<br> Table 2 : etats</p> <p>And a third table called : events</p> <p>In my table "etats"</p> <p>I have 'etat_id' and 'etat_lib'</p> <p>I would like to have the details from 1 "inscrit" with the lib of the 'etat' for the event id specified.</p> <p><strong>events.php</strong> </p> <pre><code>&lt;?php if (!defined('BASEPATH')) exit('No direct script access allowed'); class Events extends MY_Controller { public function __construct() { parent::__construct(); $this-&gt;load-&gt;model('event_model', 'event_m'); // Modele des évènements $this-&gt;load-&gt;model('inscrits_model', 'inscrits_m'); // Modele des inscrits $this-&gt;template-&gt;title('Gestion des évènements'); $this-&gt;template-&gt;data('titre', 'EVENTS'); $this-&gt;is_validated(); } public function index() { // Preparation du template $this-&gt;template-&gt;data('heading', 'Liste des evènements'); $this-&gt;template-&gt;widgets('content', 'events_list'); try { // On recupère la liste des events $this-&gt;template-&gt;data('evt', $this-&gt;event_m-&gt;get_all(array(), array('evenement_title ASC'))); // On charge le template $this-&gt;template-&gt;load(); } catch (Exception $e) { echo $e-&gt;getCode() . " =&gt; " . $e-&gt;getMessage(); } } public function inscrits($event_id) { // Preparation du template $this-&gt;template-&gt;data('heading', 'Liste des inscrits'); $this-&gt;template-&gt;widgets('content', 'inscrits_liste'); try { // On recupère la liste des inscrits $this-&gt;template-&gt;data('inscrits', $this-&gt;inscrits_m-&gt;inscrits_event($event_id)); // On charge le template $this-&gt;template-&gt;load(); } catch (Exception $e) { echo $e-&gt;getCode() . " =&gt; " . $e-&gt;getMessage(); } } } </code></pre> <p><strong>The model :</strong></p> <pre><code>&lt;?php class inscrits_model extends MY_Model { protected $table = 'inscrits'; protected $primary = 'inscrits_id'; public function inscrits_event($event_id) { $this-&gt;db-&gt;select('inscrits_id,inscrits_pseudo,inscrits_nom,inscrits_prenom,inscrits_email,etat_lib'); $this-&gt;db-&gt;from('inscrits'); $this-&gt;db-&gt;join('etats', 'inscrits.inscrits_etat_id = etats.etat_id', 'inner'); $this-&gt;db-&gt;where('inscrits_evenement_id', $event_id); $joint = $this-&gt;db-&gt;get(); return $joint; } } /* End of file admin_model.php */ /* Location: ./application/models/admin_model.php */ </code></pre> <p>The problem is to use the specific event_id to make the request on 1 inscrit for the current event.</p> <p>I can't find the mechanism :s</p> <p>I know the model do the query, the controller use the model to send datas to the view. But in my case , in the model I would like to use a data given from a row in the view (the current event_id).</p> <p>I'm lost!</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload