Welcome Guest, Not a member yet? Register   Sign In
Query Builder Class
#1

(This post was last modified: 08-21-2020, 11:27 PM by jreklund.)

Please I need some help the Query Builder Class, this should be simple but i´ve been several days trying to solve it.

This is my Controller function, wich recieves data via POST from a IOT device:

PHP Code:
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."# "// Line 27
    
}else{
           echo 
"access denied";
    }



And this is my model:

PHP Code:
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;



Everything works fine when the field 'device_sn' in WHERE clause is a numeric value (INT, BIGINT, etc) but i need this field to be a VARCHAR

'device_sn' is the device serial number and it contains characters too.


I get this:

A PHP Error was encountered</h4><p>Severity: Notice</p><p>Message: Undefined offset: 0</p><p>Filename: controllers/Getdata.php</p><p>Line Number: 27

Line 27 in Getdata controller is the one with "// Line 27" above. This is the same error i get when there is not device matching the serial number, but in this case in sure the serial number exists ... i only change the data type in 'device_sn' field from INT to varchar and quits working


Many thanks in advance !!!


Patrick
Reply


Messages In This Thread
Query Builder Class - by patricio - 08-21-2020, 05:30 PM
RE: Query Builder Class - by jreklund - 08-21-2020, 11:32 PM
RE: Query Builder Class - by InsiteFX - 08-22-2020, 03:52 AM
RE: Query Builder Class - by patricio - 08-22-2020, 03:54 AM
RE: Query Builder Class - by InsiteFX - 08-22-2020, 08:04 AM



Theme © iAndrew 2016 - Forum software by © MyBB