I can not fetch information from a MS SQL database through ODBC and with Codeigniter query Builder

Asked

Viewed 25 times

0

Good,

I am trying to create a login page with Codeigniter.

It turns out, to validate the entered data, I need to fetch information from a MS SQL database through ODBC. When using the Codeigniter query Builder, I get the following error:

Call to Undefined method Ci_db_odbc_driver::select()

What is the reason for this to happen?

Model

class Utilizador_model extends CI_Model {

public function login($username,$password){
    $this->db->select('*');
    $this->db->from('utilizadores');
    $this->db->where('username', $username);
    $this->db->where('password', $password);
    $q = $this->db->get();

    if ($q->num_rows() > 0) {
     return $q->result_array();
    }else{
        return false;
    }
}
  • Which version of CI are you using? From what I remember from version 3.1 it is no longer possible to use the CI Query Builder with ODBC. If using the Builder query, try using SQLSRV (https://www.php.net/manual/en/book.sqlsrv.php) instead of ODBC, it should work.

  • I’m using the 3.1.10.

  • I tried it without CI query Builder and it’s working

  • So that’s exactly the point. In this version Query Builder no longer works with ODBC, if you don’t use Query Builder it will work normally, or you can use another driver like SQLSRV to use QB.

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.