1
How to get data from multiple tables at once?
I need to recover the data of the following object (debtor).
There are several tables where the main table is tbl_devedor.
After that, there are others, which are related to tbl_devedor.
Example:
tbl_devedortbl_emailid_contratoid_telefoneid_endereco
Follows below the array
$dados = array(
'contratos' => [],
'id' => '',
'id_operador' => 0,
'pessoa_fisica' => array(
'id' => 0,
'rg' => '',
'dt_nascimento' => '',
'profissao' => '',
'salario' => '',
'genero' => '',
),
'pessoa_juridica' => array (
'id' => 0,
'nome_fantasia' => '',
'inscricao_estadual' => ''
),
'nome' => '',
'cpf_cnpj' => '',
'emails' => [],
'enderecos' => [],
'telefones' => [],
'crud' => null
);
echo json_encode($dados);
Remembering that contratos, pessoa_fisicao, pessoa_juridica, emails, enderecos, telefones, comes from different tables, so far what I have is this:
Controller
$devedor = $this->devedor->obter_por_id($id);
Model
public function obter_por_id($id)
{
$this->db->from($this->tbl_devedor);
$this->db->where('id',$id);
$query = $this->db->get();
return $query->row();
}
I know how to do the Join and get the data from the other tables, but I don’t know how the structure of array.

Wagner you need to put in your question the bank diagram with these tables.
– novic
Okay! Done that.
– Wagner Fillio