Join fixes in PHP

0

I have a query that brings all the users of the database, but I need to make a comparison with another table in which there is no relationship. I do everything through php but I need to join the data from the other table with the first one, that is, having everything.

Code:

$instructores = array();

$instructoresActivos = $this->Usuario->query("select * from usuarios");
$fechas = $this->Usuario->query("select * from fechas");
foreach($instructoresActivos as $instructorActivo){
     $instructores = array_merge($instructorActivo,$instructores);

}

The problem is that it only brings me the first record and I do not know why. Any solution? Thanks.

    
asked by R3d3r 82 27.10.2018 в 22:03
source

1 answer

0

When you perform the instruction

$instructoresActivos = $this->Usuario->query("select * from usuarios");

$ instructorsActivos is not an array, it is what in PHP I think is called recorset.

to get an array that contains all the instructors you should write the following instruction

$arrayInstructoresActivos=$instructoresActivos->fetchAll(PDO::FETCH_OBJ);

It would only be merged with the other array

foreach($arrayInstructoresActivos as $instructorActivo){
 $instructores = array_merge($instructorActivo,$instructores);}
    
answered by 27.10.2018 в 22:40