I have a problem with the database.
I have 3 tables. a) notebook b) category_notes c) domains
I have domain.id in the 'domains' table.
In the 'notes' table, I have domain_id and notes_category_id.

In the 'notes_category' table, I have id, notes_category_name
Script action: Saves notes for a given domain.
Everything works correctly - the data is saved and read.
Now I would like to add a note type, I have already done this functionality - but I'm showing the ID of the note type and not its name.
Of course, I have a relationship that's dear.
Controller domains.php
public function notes($id)
{
$this->load->model('admin/notes_model');
$result = $this->notes_model->get_by_domain_id($id);
echo '{"records":' . json_encode( $result ) . '}';
}
Model - domains_category_model.php
public function get($id = false)
{
if ( $id == false) {
$q = $this->db->get('notes_category');
$q = $q->result();
}
else{
$this->db->where('id', $id);
$q = $this->db->get('notes_category');
$q = $q->row();
}
return $q;
}
Controller - notes_category.php
public function get($id = false)
{
$result = $this->notes_category_model->get($id);
echo '{"records":' . json_encode( $result ) . '}';
}
Controller - notes.php
public function get($id = false)
{
$result = $this->notes_model->get($id);
echo '{"records":' . json_encode( $result ) . '}';
}
Model - Notes_model.php
public function get( $id = false)
{
if ( $id == false ) {
$q = $this->db->get('notes');
$q = $q->result();
}
else{
$this->db->where('id', $id);
$q = $this->db->get('notes');
$q = $q->row();
}
return $q;
}
public function get_by_domain_id($id)
{
$this->db->where('id_domain_rel', $id);
$q = $this->db->get('notes');
$q = $q->result();
return $q;
}
