这是我的模型:
function Countosweb(){
$sql="SELECT count(*) FROM `os` WHERE `status`='PENDIENTE ASIGNAR TÉCNICO'";
return $this->db->query($sql)->row();
}
这是我的 Controller :
public function indexp() {
if((!$this->session->userdata('session_id')) || (!$this->session->userdata('logado'))){
redirect('mapos/login');
}
$this->data['ordensW'] = $this->mapos_model->getOsWeb();
$this->data['osn']= $this->mapos_model->Countosweb($sql);
$this->data['ordens'] = $this->mapos_model->getOsAbertas();
$this->data['produtos'] = $this->mapos_model->getProdutosMinimo();
$this->data['os'] = $this->mapos_model->getOsEstatisticas();
$this->data['estatisticas_financeiro'] = $this->mapos_model->getEstatisticasFinanceiro();
$this->data['menuPainel'] = 'Painel';
$this->data['view'] = 'mapos/panel';
//$this->session->set_flashdata('success','mensaje de prueba');
$this->load->view('tema/alte',$this->data);
}
这是我的观点:
<a href="#" class="dropdown-toggle" data-toggle="dropdown">
<i class="fa fa-bell-o"></i>
<?php
if($osn != null){echo '<span class="label label-warning">'.$osn.'</span>';} // this is the line which is occasinating the problem.
?>
</a>
所以我得到了这个错误:
遇到 PHP 错误
Severity: 4096
Message: Object of class stdClass could not be converted to string
Filename:tema/alte.php
line Number: 67
请帮忙查找问题
PD:对不起,我的英语不是很好
最佳答案
你不应该使用 echo 来打印 Object - 普通情况下的返回值是 object 或 arrayuse :
print_r($osn) ;
查看输出然后循环它或使用对象 [$object_name->item]
关于php - 代码 Igniter(类 stdClass 的对象无法转换为字符串)错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36927757/