CI 2 - Language class and models
-
30-05-2021 - |
Question
I noticed an odd issue and I can't seem to find anything to explain it.
on one of my models i add an error output message to alert that a record is not available, but when it outputs, i get no text, just a blank page.
Now the language tags are valid, the only thing i can figure is that the language file isn't meant to be used on a model, if thats the case I don't see that being explained anywhere.
I hope someone can help me get in the right direction on this, if i have to just set it to false and handle the message on the ui, I'll do that, but prefer not to.
Thanks.
EDIT:
here is what a quick code snipplet that should help:
//fetch topic data.
$this->db->select('id, Name, Description, Level');
$this->db->from('groups');
$this->db->where('id', $gid);
$query = $this->db->get();
$GroupData = $query->row();
//see if we have any records to show.
if($query->num_rows() > 0) {
$this->setId($GroupData->id);
$this->setName($GroupData->Name);
$this->setDescription($GroupData->Description);
$this->setLevel($GroupData->Level);
} else {
//no record was found, throw an error.
show_error($this->lang->line('invalidgid').'<hr />File:'.__FILE__.'<br />Line:'.__LINE__, 500, $this->lang->line('error'));
log_message('error', 'invalid GroupID was provided.'); //log error in error log.
}
Solution
I feel dumb, but I figured it out, the language file hasn't loaded yet at that point, ARGH!
I will have to go back to the drawing board on this one it looks, any suggestions, please post them.