I am working with the Api rest service in Codeigniter, my query is:
I have a json that returns all the students of the mini system1, in the mini system 2 I have a table called Assign where I keep the id of the student and other data, my problem is in making the query, that after saving a student to assign ( id_alumno
) show me the students that are not that table
This is the code I was using:
$datos=array_values(array_diff_key($jsonAlumno, $jsonAsignar));
this only compares me the id(alumno)
with the id(Asignar)
but I should compare id(Alumno)
id_alumno(Asignar)
with this would make the difference and I would get the ones that are not in the table Assign but it's not working for me obviously, and I'm re lost.
The data is like this
Table Student in the system1 that I bring with the json Table Assign in the system2 the result that I want to obtain are the students that are not in the table Assign public function compare () {
$id = $this->session->userdata('usuario_id');
$usuario = $this->Model_Usuario->find($id);
$escuela= $usuario->escuela_id;
$curl = new Curl();
$curl->get('http://localhost:8000/tesis/alumnorest/alumno?format=json');
$jsonA = $curl->response;
$jsonAlumno=json_decode(json_encode($jsonA), true);
$jsonAsignar= $this->Model_Asignar->all();
$long = count($jsonAsignar);
$datos=array_values(array_diff_key($jsonAlumno, $jsonAsignar));
$jsonDatos=json_decode(json_encode($datos), true);
$longitud=count($datos);
foreach ($jsonDatos as $key => $value) {
if ($value['escuela_id']==$escuela){
$datos1[] = array('id' => $value['id'],
'persona_name' => $value['persona_name'],
'persona_dni' => $value['persona_dni'],
'persona_cuil' => $value['persona_cuil'],
'curso_name' => $value['curso_name'] );
$resultado=json_encode($datos1);
}
}
echo ($resultado);
$this->load->helper('url');
}
Could you help me please that this has me head on and thanks in advance.