I have a file with a query model that I can not understand and I need to be able to change it, but changing the model stops working so it should be the same as this one, but modifying the query or at least functioning like this, this is the current file and the query gives the result:
<?php
require_once('medoo.php');
require_once('../../php/inc.php');
$database = new medoo([
'database_type' => 'mysql',
'database_name' => $DB,
'server' => $SERVIDOR,
'username' => $USUARIO,
'password' => $CLAVE,
'charset' => 'utf8'
]);
$tbl = $_GET['tabla'];
$accion = $_GET['accion'];
$tabla = $TABLA[$tbl];
$columnas['usuarios'] = ['id', 'Nombre', 'Cedula', 'Empresa', 'FechaReg', 'activo'];
var_dump($TABLA['usuarios']);
$data['usuarios'] = $database->select($TABLA['usuarios'], $columnas['usuarios']);
if ($accion == 'leer') {
$salida = [];
if ($tbl = 'usuarios') {
foreach($data[$tbl] as $llave => $dato) {
if($dato['activo']) {
array_pop($dato);
array_push($salida, $dato);
}
}
print_r(json_encode($salida, JSON_UNESCAPED_UNICODE));
}
}
function obtenerID($id, $tabla, $campo){
foreach($tabla as $dato) {
if ($dato['id'] == $id) {
return $dato[$campo];
}
}
}
?>
But I must modify that query and do it this way
SELECT * FROM usuarios u LEFT JOIN cursos r ON r.CodUsuario=u.id LEFT JOIN listadocursos c ON r.CodCurso=c.id ORDER BY u.id ASC
In the medoo.php file there is the function
public function select($table, $join, $columns = null, $where = null)
{
$query = $this->query($this->select_context($table, $join, $columns, $where));
return $query ? $query->fetchAll(
(is_string($columns) && $columns != '*') ? PDO::FETCH_COLUMN : PDO::FETCH_ASSOC
) : false;
}