虽然很少发生,但有时我的项目会在我的查询中显示错误消息。
我认为这不是因为我的查询而发生的。
有任何可能发生这种情况的建议吗?
这是我的查询示例。
select * from (
select rlog.id_issue, created.LogUser as create_by, created.LogTime as create_time,r_change.change_by,rlog.tglupt,
r_aprove.date1 as aproved_date,issue_type,nama_app,status,kondisi,logAct, r_issue.keterangan, logket, param
from (select id_issue, logAct, max(logtime) as tglupt,param, logket from r_log group by id_issue, logAct, logket,param) rlog
inner join (select Id_issue, LogUser, LogTime from r_log where LogAct like 'add%' ) created on rlog.id_issue = created.id_issue
left join r_change on rlog.id_issue = r_change.id_issue
left join r_aprove on r_change.id_change = r_aprove.id_change
left join r_issue on rlog.id_issue = r_issue.id_issue
inner join r_app_det on r_issue.id_app = r_app_det.id_app
)z where issue_type is not null
and id_issue = ".$id."
order by tglupt, case when logAct = 'Add' then '1' else logact end asc
这是我$query =$this->db->query("SELECT * FROM mUser WHERE username='".$uname."'");
的数据:
-----------------------------------------
username | name | role
-----------------------------------------
ADR | andry | 2
AND | Andrew | 4
------------------------------------------
- 如果我的英语不好,那就好了。
答案 0 :(得分:0)
对于某些$ uname,你没有得到任何结果。因此,在转换为row()之前,应检查查询是否返回结果。喜欢这个
$query =$this->db->query("SELECT * FROM mUser WHERE username='".$uname."'");
if($query->num_rows() == 1){
$query->row();
}else{
//....
}
答案 1 :(得分:0)
我认为你没有使用。 $查询 - >行(); OR $ query-> result();在查询结束时。
$query =$this->db->query("select * from (
select rlog.id_issue, created.LogUser as create_by, created.LogTime as create_time,r_change.change_by,rlog.tglupt,
r_aprove.date1 as aproved_date,issue_type,nama_app,status,kondisi,logAct, r_issue.keterangan, logket, param
from (select id_issue, logAct, max(logtime) as tglupt,param, logket from r_log group by id_issue, logAct, logket,param) rlog
inner join (select Id_issue, LogUser, LogTime from r_log where LogAct like 'add%' ) created on rlog.id_issue = created.id_issue
left join r_change on rlog.id_issue = r_change.id_issue
left join r_aprove on r_change.id_change = r_aprove.id_change
left join r_issue on rlog.id_issue = r_issue.id_issue
inner join r_app_det on r_issue.id_app = r_app_det.id_app
)z where issue_type is not null
and id_issue = ".$id."
order by tglupt, case when logAct = 'Add' then '1' else logact end asc");
foreach ($query->result_array() as $row)
{
echo $row['title'];
echo $row['name'];
echo $row['body'];
}
答案 2 :(得分:0)
问题在于我的连接,我在localhost上尝试它,从来没有问题。 thx all。