diff --git a/application/core/MY_Model.php b/application/core/MY_Model.php index 741769f..245c78c 100644 --- a/application/core/MY_Model.php +++ b/application/core/MY_Model.php @@ -77,10 +77,21 @@ class MY_Model extends CI_Model{ function get_query_result(){ $query = $this->db->query($this->sql); if($query === FALSE){ - log_message('error', 'Database query failed: ' . $this->db->error()['message'] . ' | SQL: ' . $this->sql); + $error = $this->db->error(); + log_message('error', 'Database query failed: ' . $error['message'] . ' | SQL: ' . $this->sql); + // Tijdelijk ook direct tonen voor debugging + if(ENVIRONMENT !== 'production'){ + echo "SQL Error: " . $error['message'] . "\n"; + echo "SQL: " . $this->sql . "\n"; + } return FALSE; } - if($query->num_rows()==0){ + $num_rows = $query->num_rows(); + // Tijdelijk loggen voor debugging + if(ENVIRONMENT !== 'production'){ + log_message('debug', 'Query returned ' . $num_rows . ' rows | SQL: ' . substr($this->sql, 0, 100)); + } + if($num_rows == 0){ return FALSE; }else{ return $query->result(); diff --git a/application/models/monpas/Groepen_model.php b/application/models/monpas/Groepen_model.php index d9f5823..7f3d997 100644 --- a/application/models/monpas/Groepen_model.php +++ b/application/models/monpas/Groepen_model.php @@ -119,7 +119,17 @@ class Groepen_model extends MY_Model{ AND GR.module = {$module} GROUP BY GR.id, GR.naam, GR.niveau, GR.totaantal, GR.ondersteuning ORDER BY niveau, naam, GR.id "; - return $this->get_query_result(); + + // Tijdelijk debug: ook op productie loggen + error_log("=== GETGROEPEN DEBUG ==="); + error_log("orgid: $orgid, schooljaarnr: $schooljaarnr, module: $module"); + error_log("SQL: " . $this->sql); + + $result = $this->get_query_result(); + + error_log("Result: " . ($result === FALSE ? 'FALSE' : count($result) . ' rows')); + + return $result; } function getgekopieerdegroepen($orgid, $schooljaarnr, $module){ $this->sql = "SELECT GR.id,