Insert different tables of a base into an array in Codeigniter

0

The problem I have is what do I get a json of a form, by doing the json decode I get:

Array ( [curp_aval] => pemi940613hdfrdasr [nombre_aval] => Ivan [ap_pat_aval] => Perez
[ap_mat_aval] => Montiel [curp] => GACh940207hdasdfgh [nombre] => pablo javier 
[ap_pat] => gomez [ap_mat] => casol [telefono] => Array ( [0] => 1451234123 ) 
[correo] => Array ( [0] => [email protected] ) [direccion] => 5 de febrero [no_ext] => 4 
[no_int] => - [codigo_postal] => 54506 [colonia] => cuaxoxa [demarcacion] => rio frio 
[entidad_federativa] => méxico [nivel_estudio] => Licenciatura [ocupacion] => estudiante ) 

These are the fields that I will insert in my table usuario , up to this point I have no problem, the problem starts when I have to insert the phones that the user enters in my table agenda and the emails that you enter in my table correo , I do not know how to do that part in my model, since I'm using active record.

Controller

$data_array = json_decode($json_data, true);
foreach ($data_array as $data_row)

Model

$this->db->insert('usuario', $data_row);
endforeach; 

How could I insert that data into different tables?

    
asked by Imp Zerep 25.03.2017 в 19:48
source

1 answer

0

I think you should extract the email and phone array, go through them in the foreach that you have and insert where you need it, and that's how your general foreach is per user, and inside 2 you foreach one for email and another for phones.

    
answered by 31.03.2017 в 10:15