Php 执行此函数时出错
可能重复:Php 执行此函数时出错,php,codeigniter,Php,Codeigniter,可能重复: 继续从 这就是函数,$database就是从它来的 function getSearchedUniversityTab($country, $state, $level, $degType) { $query = $this->db->query("SELECT `university`.`uniId`, `university`.`name` FROM (`university`)
继续从 这就是函数,$database就是从它来的
function getSearchedUniversityTab($country, $state, $level, $degType) {
$query = $this->db->query("SELECT `university`.`uniId`, `university`.`name`
FROM (`university`)
inner JOIN (select degCollege, degType, count(*) as cnt from degree where `degType` = '$degType' group by degCollege) clg
ON clg.`degCollege` = `university`.`uniId`
WHERE `country` = '$country'
AND `state` = '$state'");
$result = $query->result_array();
foreach($result as $row)
{
$data[] = $row;
}
return $data;
$this->db->close();
}
您的
结果极有可能返回空
改为
function getSearchedUniversityTab($country, $state, $level, $degType) {
$query = $this->db->query("SELECT `university`.`uniId`, `university`.`name`
FROM (`university`)
inner JOIN (select degCollege, degType, count(*) as cnt from degree where `degType` = '$degType' group by degCollege) clg
ON clg.`degCollege` = `university`.`uniId`
WHERE `country` = '$country'
AND `state` = '$state'");
$result = $query->result_array();
if(count($result) > 0 ) {
foreach($result as $row)
{
$data[] = $row;
}
return $data;
}else{
return null;
}
$this->db->close();
}
如果您有错误,请将其作为问题的引用部分,这样大家都更容易阅读…您想知道什么?因为这与您的上一个问题是同一个问题,您应该更新上一个问题。@EmilVikström是的,您是对的。遗憾的是,它不再有效了…:(