Compare commits
3
Commits
develop
...
c8fc4767a1
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c8fc4767a1 | ||
|
|
44bc260061 | ||
|
|
90b4f0d08e |
@@ -13,9 +13,11 @@
|
||||
|
||||
|
||||
class MY_Model extends CI_Model{
|
||||
|
||||
|
||||
function __construct(){
|
||||
parent::__construct();
|
||||
// Disable ONLY_FULL_GROUP_BY for legacy queries
|
||||
$this->db->query("SET sql_mode=(SELECT REPLACE(@@sql_mode,'ONLY_FULL_GROUP_BY',''))");
|
||||
}
|
||||
|
||||
function get_record_by_id($id, $fieldname=FALSE, $row=TRUE){
|
||||
@@ -74,7 +76,22 @@ class MY_Model extends CI_Model{
|
||||
|
||||
function get_query_result(){
|
||||
$query = $this->db->query($this->sql);
|
||||
if($query->num_rows()==0){
|
||||
if($query === FALSE){
|
||||
$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;
|
||||
}
|
||||
$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();
|
||||
|
||||
@@ -117,9 +117,19 @@ class Groepen_model extends MY_Model{
|
||||
AND GR.schooljaarnr = {$schooljaarnr}
|
||||
AND GR.schooltype = 'R'
|
||||
AND GR.module = {$module}
|
||||
GROUP BY GR.id
|
||||
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,
|
||||
@@ -146,7 +156,7 @@ class Groepen_model extends MY_Model{
|
||||
AND GR.schooljaarnr = {$schooljaarnr}
|
||||
AND GR.schooltype = 'R'
|
||||
AND GR.module = {$module}
|
||||
GROUP BY GR.id
|
||||
GROUP BY GR.id, GR.naam, GR.niveau, GR.totaantal
|
||||
ORDER BY niveau, naam, GR.id ";
|
||||
return $this->get_query_result();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user