Php 如何仅获取缺勤日期和缺勤学生id的值
这里我正在做一个考勤模块,这意味着谁都缺席,我将他们的id作为json字符串存储在数据库中,这里实际上id 1在2017-04-11和2017-04-12Php 如何仅获取缺勤日期和缺勤学生id的值,php,codeigniter,Php,Codeigniter,这里我正在做一个考勤模块,这意味着谁都缺席,我将他们的id作为json字符串存储在数据库中,这里实际上id 1在2017-04-11和2017-04-12 id 2缺席2017-04-11和2017-04-13,到目前为止工作正常,在这里我想做的是,我有一个动态变量,如loginId=2,我想显示id 2的结果,如他缺席的日期,请参见下面我的预期结果 学生缺席名单(表名) 我的控制器 我的模型 我的预期结果 最新答案 尝试按以下方式重写您的模型: 将控制器重写如下: 我没有得到预期的结果,请查
id 2缺席2017-04-11和2017-04-13,到目前为止工作正常,在这里我想做的是,我有一个动态变量,如loginId=2,我想显示id 2的结果,如他缺席的日期,请参见下面我的预期结果 学生缺席名单(表名) 我的控制器 我的模型 我的预期结果 最新答案 尝试按以下方式重写您的模型: 将控制器重写如下:
我没有得到预期的结果,请查看我的更新答案非常感谢@Sachin PATIL先生,我现在得到了解决方案我投票结束这个问题,因为StackOverflow不是一个免费的众包代码生成器。
absendId studentAbsentId studentAbsentDate schoolId
1 ["1","2"] 2017-04-11 2
2 ["1"] 2017-04-12 2
3 ["2"] 2017-04-13 2
public function getAbsentListStaff()
{
date_default_timezone_set('Asia/Kolkata');
$loginType = $_POST['loginType'];
if($loginType == 1)
{
$data = array(
"schoolId" => $_POST['schoolName'],
"classId" => $_POST['className'],
"sectionId" => $_POST['sectionName'],
"loginId" =>$_POST['loginId'],
);
$absentresponse= $this->Android_login_model->admin_options_listdisplayparent($data);
foreach ($absentresponse as $key => $value)
{
$absentresponse[$key]->studentAbsentId= json_decode($value->studentAbsentId,true);
}
if($absentresponse){
$return=array('status'=>"Success",'data'=>$absentresponse);
echo json_encode($return);
}
else{
$return=array('status'=>"Error",'description'=>"Data Not Found");
echo json_encode($return);
}
}
}
public function admin_options_listdisplayparent($params)
{
$this->db->select('*');
$this->db->where('status !=', '1');
$this->db->where('schoolId =',$params['schoolId']);
$this->db->where('classId =',$params['classId']);
$this->db->where('sectionId =',$params['sectionId']);
//$this->db->where('studentAbsentDate =',$params['absentDate']);
return $this->db->get('student_absent_list')->result();
}
{
"status": "Success",
"data": [
{
"studentAbsentId": "2"
"studentAbsentDate": "2017-04-11",
"schoolId": "2",
"response":"absent"
},
{
"studentAbsentId": "2"
"studentAbsentDate": "2017-04-13",
"schoolId": "2",
"response":"absent"
}
]
}
{
"status": "Success",
"data": [
{
"absendId": "1",
"studentAbsentId": [
"1",
"2"
],
"studentAbsentDate": "2017-04-11",
"schoolId": "2",
"classId": "1",
"sectionId": "1",
"reg_date": "2017-04-13 01:01:03",
"created_by": "kanniyappan@g2evolution.co.in",
"status": "0"
},
{
"absendId": "2",
"studentAbsentId": [
"1"
],
"studentAbsentDate": "2017-04-12",
"schoolId": "2",
"classId": "1",
"sectionId": "1",
"reg_date": "2017-04-13 01:01:14",
"created_by": "kanniyappan@g2evolution.co.in",
"status": "0"
}
]
}
public function admin_options_listdisplayparent($params)
{
$condition = array(
'status !=' => '1',
'schoolId' => $params['schoolId'],
'classId' => $params['classId'],
'sectionId' => $params['sectionId']
);
$this->db->select('*');
$this->db->where($condition);
$this->db->like('studentAbsentId', '"' . $params['loginId'] . '"', 'both');
return $this->db->get('student_absent_list')->result();
}
public function getAbsentListStaff() {
date_default_timezone_set('Asia/Kolkata');
$loginType = $_POST['loginType'];
if($loginType == 1)
{
$data = array(
"schoolId" => $_POST['schoolName'],
"classId" => $_POST['className'],
"sectionId" => $_POST['sectionName'],
"loginId" =>$_POST['loginId'],
);
$absentresponse_data= $this->Android_login_model->admin_options_listdisplayparent($data);
$absentresponse = array();
foreach ($absentresponse_data as $res)
{
$row = array();
$row['studentAbsentId'] = $_POST['loginId'];
$row['studentAbsentDate'] = $res->studentAbsentDate;
$row['schoolId'] = $res->schoolId;
$row['response'] = 'absent';
$absentresponse[] = $row;
}
if(count($absentresponse) > 0){
$return = array('status'=>"Success",'data'=>$absentresponse);
echo json_encode($return);
} else {
$return = array('status'=>"Error",'description'=>"Data Not Found");
echo json_encode($return);
}
}
}