查询生成器类-CodeIgniter 4

问题描述

请给我一些查询生成器类的帮助,这应该很简单,但是我已经花了好几天试图解决它。

这是我的Controller函数,它通过POST从IOT设备接收数据:

int temp =  execv("#!/usr/bin/ruby xmlReader.rb",list);
if (spec == -1)
      printf("%s\n",strerror(errno));

这是我的模型:

public function gettopics(){

    $password = strip_tags($this->input->post('gdp'));

    if ($password == GET_DATA_PASSWORD){

           $device_sn = strip_tags($this->input->post('sn'));
           $result = $this->Getdata_model->gettopics($device_sn);
           **** echo "<br>#".ROOT_TOPIC."/".$result[0]['device_topic']."#".MQTT_USER."#".MQTT_PASSWORD."# ";
    }else{
           echo "access denied";
    }
}

当WHERE子句中的“ device_sn”字段为数字值(INT,BIGINT等)时,一切正常,但我需要将此字段作为VARCHAR。

'device_sn'是设备序列号,它也包含字符。

我明白了:

public function gettopics($device_sn){ $this->db->SELECT('device_topic'); $this->db->FROM('devices'); $this->db->WHERE('device_sn',$device_sn); $result = $this->db->get()->result_array(); return $result; }

Getdata控制器中的第27行是标有****(回音)的行。这是当没有与序列号匹配的设备时遇到的相同错误,但是在这种情况下,请确保序列号存在...我只将'device_sn'字段中的数据类型从INT更改为varchar并退出工作。 / p>

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)