• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Error connecting to SQLServer

#1
Hi everyone. I am new to CI4 and wanted to upgrade my website to CI4, but I am having trouble connecting to the SQLServer database.
My connection details are these

PHP Code:
public $default = [
        
'DSN'      => '',
        
'hostname' => 'xxx.xxx.xxx',
        
'username' => 'my_user',
        
'password' => 'my_pass',
        
'database' => 'my_DB',
        
'DBDriver' => 'sqlsrv',
        
'DBPrefix' => '',
        
'pConnect' => false,
        
'DBDebug'  => (ENVIRONMENT !== 'production'),
        
'cacheOn'  => false,
        
'cacheDir' => '',
        
'charset'  => 'utf8',
        
'DBCollat' => 'utf8_general_ci',
        
'swapPre'  => '',
        
'encrypt'  => false,
        
'compress' => false,
        
'strictOn' => false,
        
'failover' => [],
        
'port'     => 3306,
    ]; 

After testing the connection I get this error:

Error

Class '\CodeIgniter\Database\sqlsrv\Connection' not found

[b]SYSTEMPATH/Database/Database.php at line 85[/b]


Code:
78             throw new \InvalidArgumentException('You have not selected a database type to connect to.');
79         }
80
81         $className = strpos($params['DBDriver'], '\\') === false
82             ? '\CodeIgniter\Database\\' . $params['DBDriver'] . '\\Connection'
83             : $params['DBDriver'] . '\\Connection';
84
85         $class = new $className($params);
86
87         // Store the connection
88         $this->connections[$alias] = $class;
89
90         return $this->connections[$alias];
91     }
92




I have tested the connection with php and it connects correctly
PHP Code:
<?php
    $serverName 
"xxx.xxx.xxx";
    $connectionOptions = array(
        "Database" => "my_DB",
        "Uid" => "my_user",
        "PWD" => "my_pass"
    );
    //Establishes the connection
    $conn sqlsrv_connect($serverName$connectionOptions);
    if($conn)
        echo "Connected!"
?>


please. Can you help me?

Thank you so much everyone! Smile
Reply

#2
I don't believe CI4 supports SQLServer yet - so far there's only MySQLi, Postgre, and SQLite3 from what I see in the code.
Reply


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.