0
I’m trying to fix this bug:
Severity: Notice Message: Trying to get Property of non-object Filename: contracts/view.php Line Number: 37
CODE:
contratos_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;
}
php contracts.
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);
}
visualize.php
<?
print_r($result);
?>
return of the viewer print_r
Array ( [0] => stdClass Object ( [idContrato] => 3 [idCliente] => 3 [idCedente] => 2 [forma_de_pagamento] => 96 [nota_fiscal] => 94 [fechamento_de] => 1 [fechamento_a] => 1 [vencimento] => 1 [guias] => 0 [status] => 0 [curso] => Array ( [0] => stdClass Object ( [idCliente] => 3 [razaosocial] => PIXX CRIATIVA SOLUCOES LTDA [nomefantasia] => PIXX CRIATIVA SOLUCOES LTDA [cnpj] => 0655544801120 [ie] => 0 [im] => 0 [endereco] => [endereco_numero] => 0 [endereco_complemento] => [endereco_bairro] => [endereco_cep] => 0 [endereco_cidade] => [endereco_estado] => 12 [responsavel] => André Baill [responsavel_phone_ddd] => 41 [responsavel_telefone] => 96479364 [responsavel_celular_ddd] => 0 [responsavel_celular] => 0 [email] => [data_ativo] => 1970-01-01 [codCedente] => 4 [fat_endereco] => [fat_endereco_numero] => 0 [fat_endereco_complemento] => [fat_endereco_bairro] => [fat_endereco_cep] => 0 [fat_endereco_cidade] => [fat_endereco_estado] => 12 [fat_responsavel] => [fat_telefone_ddd] => 0 [fat_telefone] => 0 [fat_celular_ddd] => 0 [fat_celular] => 0 [email_financeiro] => [vencimento] => 1 [nota] => 94 [fechamento_de] => 1 [fechamento_a] => 1 [guias] => 0 [valor_moto_normal] => 0 [valor_moto_metropolitano] => 0 [valor_moto_depois_18] => 0 [valor_moto_km] => 0 [valor_carro_normal] => 0 [valor_carro_metropolitano] => 0 [valor_carro_depois_18] => 0 [valor_carro_km] => 0 [valor_caminhao_normal] => 0 [valor_caminhao_metropolitano] => 0 [valor_caminhao_depois_18] => 0 [valor_caminhao_km] => 0 [status] => 0 ) ) ) )
I also cheated on the Pastebin
I’ve been trying for days and I can’t print the data properly.
Tend to give a echo $result->campo
Ai gives the message above.
Which version of the IC is?
– rray
The version is version 2.1.3
– Sr. André Baill
Could evidence the line that error occurs?
– rray
Line 37: <td><? php echo $result->idContract; ? ></td>
– Sr. André Baill
have tried
echo $result[0]->campo
– Marcelo Diniz
How do I retrieve the data that was printed in the $result[client]?
– Sr. André Baill
I didn’t understand the pq of that
foreach
in thegetById()
, think q da to simplify a little.– rray
The final function was like this: and it worked.
– Sr. André Baill
Why a foreach if you gave a limit 1? Uses Row() instead of result();
– Kayo Bruno
@Andrébaill, enjoy and see how the website works it is different from a forum.
– rray