为代码“DateTime::createFromFormat”的 foreach ()

我在 codeigniter 中设置它,以便时间戳在数据库中的格式为 (yyyy-mm-dd hh: ii: ss) 到 (yyyy-mm-dd)



    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();

        }


文件 database/DB_query_build.php 中的代码无效


public function select($select = '*', $escape = NULL)

    {

        if (is_string($select))

        {

            $select = explode(',', $select);

        }


        // If the escape value was not set, we will base it on the global setting

        is_bool($escape) OR $escape = $this->_protect_identifiers;


        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;

                }

            }

        }


        return $this;

    }

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


行号:294


慕姐8265434
浏览 166回答 2
2回答

尚方宝剑之说

打印 $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;            }           }          }}

一只甜甜圈

您的查询有误。您可以将登录功能替换如下。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();}
打开App,查看更多内容
随时随地看视频慕课网APP