为什么无法从 sqlsrv ci3 获取查询

Why can't get query from sqlsrv ci3

//这是我的配置数据库:

'dsn'   => '',
'hostname' => '10.***.***.*',
'username' => 'username',
'password' => 'password',
'database' => 'mydb',
'dbdriver' => 'sqlsrv',
'dbprefix' => '',
'pconnect' => FALSE,
'db_debug' => FALSE,
'cache_on' => FALSE,
'cachedir' => '',
'char_set' => 'utf8',
'dbcollat' => 'utf8_general_ci',
'swap_pre' => '',
'encrypt' => FALSE,
'compress' => FALSE,
'stricton' => FALSE,
'failover' => array(),
'save_queries' => FALSE

//我的模型

class Mod_login extends CI_Model{
function Aplikasi(){

    $sql = "SELECT * FROM aplikasi";
    $data = $this->db->query($sql);
    var_dump($data);
    die();
    if (!$data) {
        return false;
    } else {
        return $data;
    };
}

}

//这是我的控制器

public function index()
{
    $logged_in = $this->session->userdata('logged_in');
    if ($logged_in == TRUE) {
        redirect('dashboard');
    } else {
        $aplikasi['aplikasi'] = $this->Mod_login->Aplikasi();
        $this->load->view('admin/login_data', $aplikasi);
    }
} 

嗨,我是新手,我与 sqlsrv 的连接有问题,我已经下载了 php 8.02 的扩展,确保我的用户名和密码无法访问 table,但仍然无法获取结果,真是郁闷

试试这个

class Mod_login extends CI_Model{ function Aplikasi(){

  $sql = "SELECT * FROM aplikasi";
  $data = $this->db->query($sql);
  var_dump($data>result_array());
  die();
  if (!$data) {
      return false;
  } else {
      return $data;
  };
}

如果您有“消息:调用成员函数 result_array() on bool”,您可能没有加载数据库 class

读这个Initializing the Database Class

或者看看他展示了什么 var_dump($this->db)