0
Recently I started developing in PHP+Mysql ,I’m doubtful about the query display, follow scenario.
I’m making select with 3 tables mdl_logstore_standard, mdl_course and mdl_user, where on the table mdl_logstore_standard contains FK of mdl_course (courseid) and in the table mdl_user (userid),when executing query in the database console returns all record (including duplicates), but when I debug in PHP returns the record without duplicates.
I’d like you to return all records including duplicates:
Query:
SELECT u.firstname AS 'USUARIO',
   u.department AS 'DEPARTAMENTO', 
   l.id AS 'ID_LOG', 
   eventname, action, FROM_UNIXTIME(l.timecreated),
   l.courseid as 'COD_CURSO', 
   c.id AS 'ID CURSO mdl_course',
c.fullname AS 'DESCRICAO CURSO'   
FROM mdl_logstore_standard_log l,
   mdl_course c,
   mdl_user u  
WHERE    
   l.courseid = c.id AND l.userid =  u.id 
ORDER BY l.timecreated DESC LIMIT 50
PHP.
 $sql ="SELECT u.firstname AS 'USUARIO',
        u.department AS 'DEPARTAMENTO', 
        l.id AS 'ID_LOG',   
        eventname, action, FROM_UNIXTIME(l.timecreated),   
        l.courseid as 'COD_CURSO', c.id AS 'ID CURSO mdl_course',   
        c.fullname AS 'DESCRICAO CURSO'   
        FROM   mdl_logstore_standard_log l,mdl_course c , mdl_user u  
        WHERE l.courseid = c.id   AND  l.userid =  u.id 
        ORDER BY l.timecreated DESC LIMIT 50";
Implementation of the consultation:
$start_consulta = $DB->get_records_sql($sql);
Query display:
echo "<pre>";
print_r ($start_consulta); 
echo "</pre>";
What is within the method
get_records_sql?– Marcelo de Andrade
Parameters connection Database ,I am developing for environment AVA Moodle, integrated system.
– Rafael Luz