CodeIgniter Forums
How to connect SQLSRV using SQLSRV driver? - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: CodeIgniter 4 (https://forum.codeigniter.com/forumdisplay.php?fid=28)
+--- Forum: CodeIgniter 4 Support (https://forum.codeigniter.com/forumdisplay.php?fid=30)
+--- Thread: How to connect SQLSRV using SQLSRV driver? (/showthread.php?tid=78609)



How to connect SQLSRV using SQLSRV driver? - ajmeireles - 02-14-2021

With the latest CI4 version I'm able to use SQLSRV driver to DB Connections, but I'm understand how I can configure the driver to be connectec successfully? I've tried:

PHP Code:
    public $mulord = [
        
'DSN'      => '',
        
'hostname' => 'IP_HERE',
        
'username' => 'sa',
        
'password' => 'PASS',
        
'database' => 'DB_NAME',
        
'DBDriver' => 'SQLSRV',
        
'DBPrefix' => '',
        
'pConnect' => false,
        
'DBDebug'  => (ENVIRONMENT !== 'production'),
        
'charset'  => 'utf8',
        
'DBCollat' => 'utf8_general_ci',
        
'swapPre'  => '',
        
'encrypt'  => true,
        
'compress' => false,
        
'strictOn' => false,
        
'failover' => [],
        
'port'     => 1433,
    ]; 

But doesn't work... Then I'm try based on this topic:
https://forum.codeigniter.com/thread-78564.html?highlight=SQLSRV

And continue without work (Unable to connect to the database).

I really will be possible to remote connect in SQL Server using SQLSRV driver?



RE: How to connect SQLSRV using SQLSRV driver? - InsiteFX - 02-15-2021

Make sure that you have installed the mssql driver right.

Read:

Connect Codeigniter PHP7.3 to MSSQL


RE: How to connect SQLSRV using SQLSRV driver? - ajmeireles - 02-15-2021

MSSQL or SQLSRV driver? We are talking about CI4, right? The tutorial you've sent is CI3.

(02-15-2021, 01:41 AM)InsiteFX Wrote: Make sure that you have installed the mssql driver right.

Read:

Connect Codeigniter PHP7.3 to MSSQL

MSSQL or SQLSRV driver? We are talking about CI4, right? You've sent a tutorial from CI3.


RE: How to connect SQLSRV using SQLSRV driver? - InsiteFX - 02-15-2021

No the point was for you to check and make sure that you have all of the Microsoft drivers installed.

It should not matter if it is CI 3 or CI 4 the configuration should be the same.


RE: How to connect SQLSRV using SQLSRV driver? - ajmeireles - 02-15-2021

1. The web is hosted in a  cPanel hosting using this PHP setup:
https://puu.sh/HgZhA/2274686967.png

2. The driver configuration has been set like this:
https://puu.sh/HgZhY/dc9dc8b968.png

3. The query (homecontroller):
https://puu.sh/HgZij/59671da1f3.png

... SQL is running and port 1433 is opened on firewall. All my other programs using pdo_dblib work fine to connect on SQL.

I honestly don't know where is the error.


RE: How to connect SQLSRV using SQLSRV driver? - FlavioSuar - 03-23-2021

Don't know if this is important, but you are using 'SQLSRV' instead of 'sqlsrv' as the driver name...

Maybe these steps can help you as a usecase...
https://futbolsalas15.wordpress.com/2014/02/23/7-steps-to-make-sql-server-and-codeigniter-works/