⚠ 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

CRUD another tables from current tables?



ceroberoz
  • profile picture
  • Member

Posted 04 October 2013 - 18:22 PM

Is that possible to create a custom field to enter its value then save it into another table in the same database? (the inserted value is not exist in the current table)

- - -

what I mean is something like this

 

insert form

===========

value a: from table a

value b: from table b

[submit]

 

 

 


voliv12
  • profile picture
  • Member

Posted 06 October 2013 - 15:32 PM

Si se puede, me cuesta escribir en ingles, por eso te lo pongo en español, espero lo puedas traducir.

 

usando "callbak_insert", mas o menos como esto:

 

$crud = new grocery_CRUD();

$crud->set_table('tabla_a');
$crud->set_subject('Movimiento');

 

$crud->callback_insert(array($this,'inserta_en_tablas'));

 

 $output = $crud->render();
 $this->_example_output($output);
 
 
function inserta_en_tablas($post_array)
        {
           $actualiza= array(                            
                                        'insert' => $this->db->insert('tabla_a', $post_array['value_a']), //si son mas de un valor solo usa $post_array.
                                        'insert' => $this->db->insert('tabla_b', $post_array['value_b'])
                                       );                  
                return $actualiza;
         }
 
 
Espero te sirva.
Saludos.

ceroberoz
  • profile picture
  • Member

Posted 21 October 2013 - 05:33 AM

no wonder I can't do it with callback_after_insert, thanks voliv12!