Call to a member function method () on string

0

I'm using CodeIgniter and, when trying to do a search in my database to see if a given line actually exists, it displays the Call to a member function checarId() on string error. Here is the code for the functions that return this error:
Function in class Responsible (the enrollment is a varchar (20) in the DB):

    function checarId($mat){
        $cont = 0;
        $this->load->database();
        $query = $this->db->query('SELECT * FROM responsavel where matricula = '.$mat);
        foreach($query->result() as $row){
            $cont++;
        }
        if($cont == 1){
            return true;
        }else{
            return false;
        }
    }

Now follows the function code that calls the function above, already in the Room class to check whether or not you can add a line to the DB:

function salvar(){
    $data = array('nome' => $this->getNome(), 'codigoresponsavel' =>$this->getResponsavel());
    $this->load->model('responsavel');
    $this->load->database();
    $existe=$this->checarExistencia($this->getNome());

    $respExiste = $this->responsavel->checarId((string)$this->getResponsavel());

    if($existe && $respExiste){
            $this->db->where('nome', $this->getNome());
            $this->db->update('sala', $data);
    }else if($respExiste){ 
        /*$this->load->model('responsavel', 'resp');
        if($this->resp->checarId((string)$this->getResponsavel())){*/
            $this->db->insert('sala', $data);
        /*}
        else{
            $this->load->view('index');
        }*/
    }else{
        $this->load->view('index');
    }
}
    
asked by anonymous 07.10.2017 / 21:26

0 answers