⚠ 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 no save en BD



KWD

KWD
  • profile picture
  • Member

Posted 10 May 2013 - 06:02 AM

hello I'm new to this but I have a problem follow the examples and several forum post but not that set_relation_n_n not guerdan in the database I hope someone help me I will put the code below

 

 

These are the tables

componentes

num_int_com primary key auto_increment
num_ext
num_parte
descripcion

 

productos

 

num_int_pro primary key auto_increment
num_ext
descripcion

 

 

rel_com_pro
prority primary key auto_increment
num_int_com foreig key
num_int_pro  foreig key

 function productos()
  {
    try{
    /* Creamos el objeto */
    $crud = new grocery_CRUD();
    /* Seleccionamos el tema */
    $crud->set_theme('flexigrid');
    /* Seleccionmos el nombre de la tabla de nuestra base de datos*/
    $crud->set_table('productos');
    /* Le asignamos un nombre */
    $crud->set_subject('Productos');
    /* Asignamos el idioma español */
    $crud->set_language('spanish');
    /* Aqui le decimos a grocery que estos campos son obligatorios */
    $crud->required_fields(
      'num_int_pro',
      'num_ext',
      'num_parte',
      'descripcion',
      'precio_compra',
      'precio_venta',
      'stock',
      'ubicacion_bodega'
    );
    /* Aqui le indicamos que campos deseamos mostrar */
    $crud->columns(
      'num_int_pro',
      'num_ext',
      'num_parte',
      'descripcion',
      'precio_compra',
      'precio_venta',
      'stock',
      'ubicacion_bodega',
      'imagen'
    );
    //////////////////////////////////////////
    $crud->set_relation_n_n('componentes que necesita el producto', 'rel_com_pro', 'componentes', 'num_int_pro', 'num_int_com', 'descripcion','priority');
    //////////////////////////////////////////
    /* Generamos la tabla */
    $output = $crud->render();
    /* La cargamos en la vista situada en
    /applications/views/componentes/administracion.php */

    
    $this->load->view('vista', $output);
    }catch(Exception $e){
      /* Si algo sale mal cachamos el error y lo mostramos */
      show_error($e->getMessage().' --- '.$e->getTraceAsString());
    }
  } 
 

 


davidoster

davidoster
  • profile picture
  • Member

Posted 10 May 2013 - 09:38 AM

Your set_relation_n_n seems fine I think.

Try to comment out ( // ) the required_fields to see what happens.


KWD

KWD
  • profile picture
  • Member

Posted 10 May 2013 - 18:35 PM

thanks for all the help


voghDev

voghDev
  • profile picture
  • Member

Posted 30 March 2015 - 10:46 AM

See this thread:

 

/topic/2821-little-question-about-a-n-n-relation/

 

And post comment if you find a solution!