Codeigniter 中非对象的未定义变量和属性



我收到以下 3 个变量的错误消息:

消息 1(未定义的变量:行 消息 2( 尝试获取非对象的属性

编辑:(终于找到了编辑按钮(,所以 3 个变量是:

$anatomic_code = $rows->NerveCode;
$ProxAccess = $rows->ProxAccess;
$DistAccess = $rows->DistAccess;

在我看来,正是上述3行给了我两个错误。

我没有包含该模型,因为我认为问题不存在,更重要的是因为它的代码相当多,因为开发人员在我之前使用了许多不同的表来存储数据......但是,如果需要,我准备发布它。

控制器 ->

function se_enkel_test()
{
$this->freakauth_light->check('submitter');
$tech_num = $this->uri->segment(6);
$this->load->model('view_single_test','',true);
$data['query'] = $this->view_single_test->query();
$data['query_tech_type'] =  $this->view_single_test->query_tech_type();
$data['query_parameters'] =  $this->view_single_test->query_parameters();
$data['query_tech_name'] =  $this->view_single_test->query_tech_name();
$data['query_test'] =  $this->view_single_test->query_test();
$data['query_temperat'] =  $this->view_single_test->query_temperat();
$data['query_semiq'] =  $this->view_single_test->query_semiq();
$data['query_conclusion'] =  $this->view_single_test->query_conclusion();
$data['query_side'] =  $this->view_single_test->query_side();
$this->load->model('mysql_create','',true);
$data['dropdown_conclusion_diagnosis'] = $this->mysql_create->get_dropdown_conclusion($tech_num);
$data['dropdown_conclusion_duration'] = $this->mysql_create->get_dropdown_duration_diagnosis();
$data['dropdown_conclusion_severity'] = $this->mysql_create->get_dropdown_severity_diagnosis();
$this->load->view('auh/se_enkel_test', $data);
}

视图 ->

elseif ($struct_id == "3") {
foreach($query->result() as $rows):
if ($rows->NerveCode > 10000 ){
echo "<h3>N." . $rows->NerveName . ") (" . $side->SideText.")</h3>";        
}
else {
echo "<h3>N." . $rows->NerveName . " (" . $rows->ProxName . " - ";
if ($rows->Code < 3000) {
echo "m.";
}
echo $rows->DistName . ") ("  . $side->SideText.")</h3>";
}
endforeach;
$anatomic_code = $rows->NerveCode;
$ProxAccess = $rows->ProxAccess;
$DistAccess = $rows->DistAccess;
}

这就是我的页面现在面临错误的样子,人们应该意识到这个页面上方有几个错误,如帖子前面所述。 但是所有 3 个变量都有相同的两个错误。

这是原始页面过去的外观。

从两个屏幕截图中,您可以看到我页面上的问题是我没有获得"段长"值..和肌肉名称: "腓蓿(脚踝 - 短指伸肌((罪。

具有函数"查询"的模型 ->

function query()
{
$exam = $this->uri->segment(3);    
$type_id = $this->uri->segment(4);
$struct_id = $this->uri->segment(5);    
$technique_id = $this->uri->segment(6);
$test_id = $this->uri->segment(7);
switch($type_id)
{
case 1:
$query_input = "SELECT EMUSCLE.*, NERVMUSCACCP.NAME AS MuscleName, NERVMUSCACCP.ShortName AS ShortMuscleName FROM EMUSCLE,NERVMUSCACCP WHERE Exam = ".$exam." AND Struct = ".$struct_id." AND EMUSCLE.MuscleCode = NERVMUSCACCP.Code;";
break;
case 2:
$query_input = "SELECT ENERVE.*, NERVMUSCACCP.NAME AS NerveName, NERVMUSCACCP.ShortName AS ShortNerveName FROM ENERVE,NERVMUSCACCP WHERE Exam = ".$exam." AND Struct = ".$struct_id." AND ENERVE.NerveCode = NERVMUSCACCP.Code;";
break;
case 3:
$query_input = "SELECT NewTable2.*, prox2.Code, prox2.Name AS DistName, prox2.ShortAccPName AS ShortDistName FROM (SELECT NewTable1.*, prox.Name AS ProxName, prox.ShortAccPName AS ShortProxName FROM (SELECT es.*,  NERVMUSCACCP.NAME AS NerveName, NERVMUSCACCP.ShortName AS ShortNerveName FROM ESEGMENT es, NERVMUSCACCP WHERE Exam = ".$exam." AND Struct = ".$struct_id." AND es.NerveCode = NERVMUSCACCP.Code) AS NewTable1 LEFT OUTER JOIN PROXDISTINFO prox ON NewTable1.ProxAccess = prox.Code) AS NewTable2 LEFT OUTER JOIN PROXDISTINFO prox2 ON NewTable2.DistAccess = prox2.Code;";
break;
case 4:
$query_input = "SELECT NewTable1.*, NERVMUSCACCP.NAME AS MuscleName, NERVMUSCACCP.ShortName AS ShortMuscleName FROM (SELECT EJNCTION.*, NERVMUSCACCP.NAME AS NerveName, NERVMUSCACCP.ShortName AS ShortNerveName FROM EJNCTION LEFT OUTER JOIN NERVMUSCACCP ON EJNCTION.NerveCode = NERVMUSCACCP.Code WHERE EJNCTION.Exam = ".$exam." AND Struct = ".$struct_id.") AS NewTable1 LEFT OUTER JOIN NERVMUSCACCP ON NewTable1.MuscleCode = NERVMUSCACCP.Code";
break;
}    
$query = $this->db->query($query_input);
return $query;
}

您似乎实际上并没有将查询结果传递给视图:

$data['query'] = $this->view_single_test->query();

如果不看到模型,就很难做出有根据的猜测。分配给 $data['query'] 的值应该是结果对象。 不是最干净的,但请尝试从模型中返回此$query->result();,并将其分配给控制器中的变量,然后将其传递给视图。

相关内容

  • 没有找到相关文章

最新更新