Codeigniter查询数组忽略第一行但显示其余行,这可能是什么原因??? ...
function index() {
$date = date('Y-m-d');
/* $result = $this->smsgateway->SendAbsentSMS(date('Y-m-d', $this->customlib->datetostrtotime($date))); */
$student = $this->stuattendence_model->student_daily_attendance($date);
print_r($student);
}
public function student_daily_attendance($date) {
$this->db->select('students.id,students.firstname,students.lastname,students.guardian_phone,students.roll_no,classes.id,classes.class,sections.id,sections.section,student_attendences.*,student_session.id,student_session.class_id,student_session.section_id,student_session.session_id');
$this->db->from('students');
$this->db->join('student_session', 'student_session.student_id = students.id');
$this->db->join('classes', 'classes.id = student_session.class_id');
$this->db->join('sections', 'sections.id = student_session.section_id');
$this->db->join('student_attendences', 'student_attendences.student_session_id = students.id');
$this->db->where('date', $date);
$query = $this->db->get();
return $query->result_array();
}
答案 0 :(得分:0)
function index() {
$date = date('Y-m-d');
/* $result = $this->smsgateway->SendAbsentSMS(date('Y-m-d', $this->customlib->datetostrtotime($date))); */
$student = $this->stuattendence_model->student_daily_attendance($date);
print_r($student);
}
public function student_daily_attendance($date) {
$this->db->select('students.id,students.firstname,students.lastname,students.guardian_phone,students.roll_no,classes.id,classes.class,sections.id,sections.section,student_attendences.*,student_session.id,student_session.class_id,student_session.section_id,student_session.session_id');
$this->db->from('students');
$this->db->join('student_session', 'student_session.student_id = students.id');
$this->db->join('classes', 'classes.id = student_session.class_id');
$this->db->join('sections', 'sections.id = student_session.section_id');
$this->db->join('student_attendences', 'student_attendences.student_session_id = students.id');
$this->db->where('DATE(date)', $date);
$query = $this->db->get();
return $query->result_array();
}
只需更改此类查询的位置$ this-> db-> where(' DATE(date)',$ date);
答案 1 :(得分:0)
道歉,数据库表记录了我删除的学生,因此显示的记录少了一个。