【发布时间】:2019-12-06 06:20:40
【问题描述】:
我试图让老师和校长的cmets出现在视野中,但无济于事。
这是一个学校网络应用程序,家长可以在其中查看各自孩子的成绩。低于分数的是老师和校长的cmets。
现在,这些 cmets 出现在学生的视野中,但我很难让它出现在家长的视野中。
这是模型:
Comment_model.php
<?php
if (!defined('BASEPATH'))
exit('No direct script access allowed');
class Comment_model extends CI_Model {
public function __construct() {
parent::__construct();
$this->current_session = $this->setting_model->getCurrentSession();
$this->current_session_name = $this->setting_model->getCurrentSessionName();
$this->start_month = $this->setting_model->getStartMonth();
}
public function TeacherComment($data)
{
$this->db->insert('teacher_comments', $data);
return $query = $this->db->affected_rows();
}
public function UpdateTeacherComment($data, $id)
{
$this->db->where('id', $id);
$this->db->update('teacher_comments', $data);
return $query = $this->db->affected_rows();
}
public function GetTeacherComment($student_id, $session_id)
{
$this->db->select('*');
$this->db->where('student_id', $student_id);
$this->db->where('session_id', $session_id);
return $this->db->get('teacher_comments')->row();
}
public function PrincipalComment($data)
{
$this->db->insert('principal_comments', $data);
return $this->db->affected_rows();
}
public function UpdatePrincipalComment($data, $id)
{
$this->db->where('id', $id);
$this->db->update('principal_comments', $data);
return $query = $this->db->affected_rows();
}
public function GetPrincipalComment($student_id, $session_id)
{
$this->db->select('*');
$this->db->where('student_id', $student_id);
$this->db->where('session_id', $session_id);
return $this->db->get('principal_comments')->row();
}
}
我正在与之战斗的控制器:
$data['teacher_comment'] = $this->Comment_model->GetTeacherComment($id, $student_session_id);
$data['principal_comment'] = $this->Comment_model->GetPrincipalComment($id, $student_session_id);
我如何正确地使用它?
观点:
<span> CLASS TEACHER'S REMARK:
<u style="text-transform: uppercase;"><?php echo $teacher_comment->teacher_comment; ?> </u>
</span><br>
<br>
<span>PRINCIPAL REMARK:
<u style="text-transform: uppercase;"><?php echo $principal_comment->principal_comment; ?></u>
</span>
【问题讨论】:
-
大部分 PHP 看起来与这个问题无关(例如
TeacherComment()、UpdateTeacherComment()、PrincipalComment()、UpdatePrincipalComment())——如果你能坚持下去,你将有更好的机会帮助人们你的问题简单而集中。您如何调用视图并将您的$data传递给它,您可以编辑您的问题并显示它吗?另外,只是为了检查一下 - 你确定有有 cmets要显示吗?
标签: codeigniter model-view-controller