我正在编码此PHP应用程序,并且我编写的公共函数未返回任何错误而没有任何错误。使用var_dump($_POST);
查看返回的内容时,我得到array(0) { }
。
我正在尝试为我的应用编写一个基本的通知系统,该系统将根据组ID以及会话中的用户是否已看到来加载后续消息。如果用户已经看到它,它将被存储在“ readsbaby”选项卡中,然后在第二次加载该函数时将其考虑在内。
尝试了不同的方法,但是都出现了混乱的错误。
型号:
public function get_follow_up_data($group_id)
{
$servername = "localhost";
$username = "root";
$password = "";
// Create connection
$myConnection= mysqli_connect("$servername","$username","$password",
"impetusb_bilal") or die ("could not connect to mysql");
$sql="SELECT pk_followup_id,report_id,report_nature, group_id, created_date
FROM users_follow_up
WHERE DATE(created_date) > DATE_SUB(CURDATE(), INTERVAL 1 DAY) AND group_id = " . $this->session->userdata['user']['group_id'] . " AND NOT EXISTS ( SELECT notification_id
FROM readsbaby
WHERE users_follow_up.pk_followup_id = readsbaby.notification_id AND users_follow_up.group_id = readsbaby.group_id AND readsbaby.user_id = " . $this->session->userdata('id') . " AND users_follow_up.report_nature = readsbaby.notification_type
)
";
$query=mysqli_query($myConnection, $sql) or die(mysqli_error($myConnection));
var_dump($_POST);
return ($query);
}
控制器:
public function show_followup_details( $id,$report_nature,$follow_up_id)
{
$report_nature = str_replace ('%20', ' ', $report_nature);
$this->session->set_userdata('page_title','Details');
if($report_nature == 'Incident Report')
{
$follow_up_status = array('is_read' => 1);
$this->db->where('pk_followup_id',$follow_up_id);
$this->db->update('users_follow_up',$follow_up_status);
$table='incident_report';
$data['data']=$this->Incident_model->get_record($table,$id);
$data['report'] = $this->Incident_model->get_report($report_nature,$id);
}
if($report_nature == 'Medication Report')
{
$follow_up_status = array('is_read' => 1);
$this->db->where('pk_followup_id',$follow_up_id);
$this->db->update('users_follow_up',$follow_up_status);
$table='medication_error_report';
$data['data']=$this->Incident_model->get_record($table,$id);
$data['report'] = $this->Incident_model->get_report($report_nature,$id);
}
if($report_nature == 'Fire Drill')
{
$follow_up_status = array('is_read' => 1);
$this->db->where('pk_followup_id',$follow_up_id);
$this->db->update('users_follow_up',$follow_up_status);
$table='fire_drill_report';
$data['data']=$this->Incident_model->get_record($table,$id);
$data['report'] = $this->Incident_model->get_report($report_nature,$id);
}
if($report_nature == 'Work Place')
{
$follow_up_status = array('is_read' => 1);
$this->db->where('pk_followup_id',$follow_up_id);
$this->db->update('users_follow_up',$follow_up_status);
$table='work_place';
$data['data']=$this->Incident_model->get_record($table,$id);
$data['report'] = $this->Incident_model->get_report($report_nature,$id);
}
if($report_nature == 'Seizure')
{
$follow_up_status = array('is_read' => 1);
$this->db->where('pk_followup_id',$follow_up_id);
$this->db->update('users_follow_up',$follow_up_status);
$table='seizure_report';
$data['data']=$this->Incident_model->get_record($table,$id);
$data['report'] = $this->Incident_model->get_report($report_nature,$id);
}
//echo '<pre>';print_r($data);exit;
$data5 = array(
'user_id' => $this->session->userdata('id'),
'notification_id' => $id ,
'isread' => '2',
'notification_type' => $report_nature,
'group_id' => $this->session->userdata['user']['group_id'],
'read_date' => date('Y-m-d H:i:sa'),
);
$this->db->insert('readsbaby', $data5);
$this->load->view("dashboard/occurance_details",$data);
}
查看
<?php
$total_count = 0;
$user_id = $this->session->userdata('id');
$group_id = $this->session->userdata('group_id');
$this->load->model('comments_model');
$follow_up_data = $this->comments_model->get_follow_up_data($group_id);
$total_count = $total_count + count($follow_up_data);
?>
<ul class="dropdown-menu notifications" role="menu" aria-labelledby="dLabel">
<div class="notification-heading">
<h4 class="menu-title" style="color: black">Notifications</h4>
</div>
<li class="divider"></li>
<div class="notifications-wrapper">
<?php if($total_count > 0) { ?>
<?php
foreach ((array) @$follow_up_data as $value2) { ?>
<a class="content" href="<?php echo base_url('comments/show_followup_details/'.$value2['report_id'].'/'.$value2['report_nature'].'/'.$value2['pk_followup_id'])?>">
<div class="notification-item">
<h4 class="item-title"><span style="font-weight: bold; text-transform: uppercase"><?= @$value2['created_by_name']?></span> created a new follow up.</h4>
<p class="item-info"><?= @$value2['created_date'].' '.$value2['created_time']?></p>
</div>
</a>
<?php }?>
<?php } else {?>
<p style="padding: 0 0 0 10px">No Pending Notifications Available.</p>
<?php } ?>
</div>
</ul>
</div>
我希望执行查询并返回结果