I'm trying to solve this error:
Severity: Notice Message: Trying to get property of non-object Filename: contracts / visual.php Line Number: 37
CODE:
contract_model.php
public function getById($id){
$this->db->where('idContrato',$id);
$this->db->limit(1);
$consulta = $this->db->get('contrato')->result();
foreach($consulta as &$valor){
$this->db->where('idCliente', $valor->idCliente);
$valor->curso = $this->db->get('cliente')->result();
}
return $consulta;
}
contracts.php
public function visualizar(){
if(!$this->permission->checkPermission($this->session->userdata('permissao'),'vContrato')){
$this->session->set_flashdata('error','Você não tem permissão para visualizar Contratos.');
redirect(base_url());
}
$this->data['custom_error'] = '';
$this->data['result'] = $this->contratos_model->getById($this->uri->segment(3));
$this->data['view'] = 'contratos/visualizar';
$this->load->view('tema/topo', $this->data);
}
visual.php
<?
print_r($result);
?>
Viewer print_r return
Array ([0] => stdClass Object ([idContract] => 3 [idClient] => 3 [idChange] => 2 [payout_form] => 96 [fiscal_note] => 94 [ > 1 [tabs] => 0 [status] => 0 [course] => Array ([0] => stdClass Object 3 [Raisosocial] => PIXX CREATIVE SOLUCOES LTDA [nomefantasia] => PIXX CREATIVE SOLUCOES LTDA [cnpj] => 0655544801120 [ie] => 0 [im] => 0 [ > [address_number] => [address_number] => [[address_completion]]>> [ [address_number] => 0 [address_number] => [address_number] => > = [Gmail] => gmail => gmail => gmail => gmail => gmail => gmail => gmail = => 4 [fat_endereco] => [fat_endereco_number] => 0 [fat_endereco_complemento] => [fat_endereco_boirro] => [fat_endeco_number] => ereco_cep] = > 0 [fat_endereco_city] = > [fat_endereco_estado] = > 12 [fat_responsible] = > [fat_telefone_ddd] = > 0 [fat_telephone] = > 0 [fat_cellular_ddd] = > 0 [fat_cellular] = > 0 [email_finance] = > [maturity] = > 1 [note] = > 94 [closing_of] = > 1 [closure_a] = > 1 [guides] = > 0 [normal_moval_value] = > 0 [metro_moto_value] = > 0 [value_moto_depois_18] = > 0 [value_moto_km] = > 0 [normal_car_value] = > 0 [metropolitan_car_value] = > 0 [car_value_18] = > 0 [car_value] = > 0 [normal_value_value] = > 0 [Metric value] = > 0 [trail_value_18] = > 0 [value_caminhao_km] = > 0 [status] = > 0))))
I also pasped PasteBin
I've been trying for days and I can not print the data correctly.
Given a echo $result->campo
Here's the message above.