碰巧我正在通过一些Foreach从我的数据库中显示一些数据,其中我使用echo来显示我需要的每个字段的值。到目前为止,我已经在我的查询sql中使用,在WHERE任何值的条件下,我抛出一个结果来显示它,但是这个我必须通过一些变量来做,在这种情况下是$ rut_usu,它将存储从视图中的选择(列表文本)中选择车辙。但是当在模型中添加时,在sql查询中我的变量(它仍然没有值,因为我没有从listboxt中选择任何值)会引发以下错误:
An uncaught Exception was encountered
Type: ArgumentCountError
Message: Too few arguments to function M_Calendar::monday(), 0 passed in C:\xampp\htdocs\SAE\application\controllers\C_Calendar.php on line 23 and exactly 1 expected
Filename: C:\xampp\htdocs\SAE\application\models\M_Calendar.php
Line Number: 106
Backtrace:
File: C:\xampp\htdocs\SAE\application\controllers\C_Calendar.php
Line: 23
Function: monday
File: C:\xampp\htdocs\SAE\index.php
Line: 315
Function: require_once
这会是什么解决方案?我应该以其他方式做我需要的吗?
我留下我的代码:
控制器:
public function index(){
$this->load->view('layouts/Header.php');
$this->load->view('layouts/Menu.php');
$this->load->model('M_Calendar');
$data['monday'] = $this->M_Calendar->monday();
$data['tuesday'] = $this->M_Calendar->tuesday();
$data['Wednesday'] = $this->M_Calendar->wednesday();
$data['thursday'] = $this->M_Calendar->thursday();
$data['friday'] = $this->M_Calendar->friday();
$data['saturday'] = $this->M_Calendar->saturday();
$data['usuarios'] = $this->M_Calendar->get_usuarios();
$this->load->view('usuarios/V_Consulta_Horarios.php',$data);
$this->load->view('layouts/Footer.php');
}
模特(从星期一到星期六,我有几个这样的函数)
public function monday($rut_usu){
$this->db->select('MIN(horario.hrs_ini) AS hrs_ini, MAX(horario.hrs_ter) AS hrs_ter ');
$this->db->from('horario');
$this->db->join('usuarios','horario.rut_usu = usuarios.rut_usu');
$this->db->where('usuarios.rut_usu',$rut_usu);
$this->db->where('horario.lunes','ATTE. ESTUDIANTES');
$this->db->where('fecha_registro = (SELECT MAX(fecha_registro) FROM horario)');
$this->db->limit('14');
$monday = $this->db->get();
if($monday->num_rows() > 0 ){
return $monday->result();
}
}
我使用fullcalendar在javascript中显示它们的变量,正如我之前提到的那样效果很好
businessHours: [ // specify an array instea
{
dow: [ 1], // Monday
<?php foreach($monday as $row){?>
start: '<?php $inicio= "00:00"; $start1_ok = $row->hrs_ini;
if (empty($start1_ok)) { echo $inicio;}
else { echo $start1_ok;} ?>',
end: '<?php echo $row->hrs_ter ;?>'
<?php }?>
},