为代码“ DateTime :: createFromFormat”的foreach()提供了无效参数吗?

时间:2019-08-01 03:42:30

标签: php sql codeigniter

我在codeigniter中将其设置为使时间戳记在数据库中,格式为(yyyy-mm-dd hh:ii:ss)为(yyyy-mm-dd)

  var j = 1
  var fieldNameElement = document.getElementById("expected_output");
  function animator_repeat(){ 
    const animationClip = new THREE.AnimationClip(null,3, [track1]);
    const animationClip1 = new THREE.AnimationClip(null,3, [track]);
    const animationAction = mesh.userData.mixer.clipAction(animationClip);
    const animationAction1 = cube.userData.mixer.clipAction(animationClip1);

    animationAction.setLoop(THREE.LoopRepeat ,1);
    animationAction.play();
    mesh.userData.mixer.addEventListener( 'finished', () => {

      animationAction1.setLoop(THREE.LoopRepeat ,1);
          animationAction1.play(); 
          cube.userData.mixer.addEventListener( 'finished', () => {
          if(j<6){
             fieldNameElement.textContent = "Number: "+(j+1).toString();
             animator_repeat() 
             j = j+1 
            }
          });
     } )
  }
文件数据库/DB_query_build.php中的

代码无效


    function login($patient_ext_id,$birth_dttm) {
            $this->db->select('xocp_ehr_patient.patient_ext_id, xocp_persons.person_nm, xocp_persons.birthplace, xocp_persons.birth_dttm, xocp_persons.status_cd, xocp_persons.race_nm');
            $this->db->from('xocp_ehr_patient');
            $this->db->join('xocp_persons', 'xocp_ehr_patient.person_id = xocp_persons.person_id');
            /*$this->db->join("xocp_persons","xocp_persons.person_id = xocp_ehr_patient.patient_ext_id","left");*/
            $this->db->where('xocp_ehr_patient.patient_ext_id', $patient_ext_id);
            $tgl = $this->db->select(DateTime::createFromFormat('Y-m-d','xocp_persons.birth_dttm'));
            $this->db->where($tgl, $birth_dttm);
            /*$query =  $this->db->get('xocp_persons');*/
            $query =  $this->db->get('');
            return $query->num_rows();
        }

  

严重性:警告消息:为foreach()提供了无效的参数   文件名:database / DB_query_builder.php

     

行号:294

2 个答案:

答案 0 :(得分:1)

打印$ select。是否有获取数据的数组

    if(is_array($select)){
 foreach ($select as $val)
        {
     $val = trim($val);
      if ($val !== '')
        {
        $this->qb_select[] = $val;
        $this->qb_no_escape[] = $escape;
      if ($this->qb_caching === TRUE)
     {
        $this->qb_cache_select[] = $val;
        $this->qb_cache_exists[] = 'select';
        $this->qb_cache_no_escape[] = $escape;
            }
           }
          }
}

答案 1 :(得分:0)

您的查询错误。您可以按以下方式替换登录功能。

function login($patient_ext_id,$birth_dttm) {
    $this->db->select('xocp_ehr_patient.patient_ext_id, xocp_persons.person_nm, xocp_persons.birthplace, xocp_persons.birth_dttm, xocp_persons.status_cd, xocp_persons.race_nm');
    $this->db->from('xocp_ehr_patient');
    $this->db->join('xocp_persons', 'xocp_ehr_patient.person_id = xocp_persons.person_id');
    /*$this->db->join("xocp_persons","xocp_persons.person_id = xocp_ehr_patient.patient_ext_id","left");*/
    $this->db->where('xocp_ehr_patient.patient_ext_id', $patient_ext_id);
    $this->db->having("DATE_FORMAT( xocp_persons.birth_dttm, '%Y-%m-%d') = '$birth_dttm'", "",false);
    /*$query =  $this->db->get('xocp_persons');*/
    $query =  $this->db->get('');
    return $query->num_rows();
}