⚠ In case you've missed it, we have migrated to our new website, with a brand new forum. For more details about the migration you can read our blog post for website migration. This is an archived forum. ⚠

  •     

profile picture

set_relation_n_n - retrieve information from another table



lraifort

lraifort
  • profile picture
  • Member

Posted 22 November 2019 - 13:37 PM

hello,

 

i have some difficulties to find the solution to solve my problem.

i am using set_relation_n_n function between tables registration (inscriptions), and financial transaction (transact).

One financial transaction can address one or more registration, transact_inscription is the relation table

It is working fine but instead of showing member id (adherents_id) , i would like to show the member name (nom) ,  information stored into table adherents

How can i manage it ?

My code below. i attached ERD diagram

Many thanks for your help.

 

 

<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Transactions extends CI_Controller {

function __construct()
{
         parent::__construct();

         /* Standard Libraries of codeigniter are required */
         $this->load->database();
         $this->load->helper('url');
         /* ------------------ */

         $this->load->library('grocery_CRUD');

}

public function show()
{
        $crud = new grocery_CRUD();
        $crud->set_theme('flexigrid');
        $crud->set_table('transact');
        $crud->set_relation_n_n('adherent','transact_inscription','inscriptions','transact_id','inscription_id','{adherents_id} {cotisation}', 'priority');

        $output = $crud->render();

        $this->_example_output($output);
}

function _example_output($output = null)
{

        $this->template->set('title', 'Gestion des Transactions');
        // on charge la page dans le template
        $this->template->load('template', 'transactions', $output);
}
}