CodeIgniter Forums

Full Version: Connecting to MsSQL database
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Ubuntu: 16.04 
Apache:  Apache/2.4.18 (Ubuntu)
CI: 3.1.6

I've been spinning my wheels on this for a day or two, think i need some help!  I am making a clean build, for a very old CI based application with all the new bells and whistles - But i cannot get a basic database connection to work on the new box.

class User_Model extends CI_Model
    function __construct()

$db[$active_group] = array(
    'dsn'    => '',
    'hostname' => 'THE_HOSTNAME',
    'username' =>    "THEUSERNAME",
    'password' =>    "THEPASSWORD",
    'database' =>    "THEDATABASE",
    'dbdriver' =>    "mssql",
    'dbprefix' => '',
    'pconnect' => TRUE,
    'db_debug' => (ENVIRONMENT !== 'production'),
    'cache_on' => FALSE,
    'cachedir' => '',
    'char_set' => 'utf8',
    'dbcollat' => 'utf8_general_ci',
    'swap_pre' => '',
    'encrypt' => FALSE,
    'compress' => FALSE,
    'stricton' => FALSE,
    'failover' => array(),
    'save_queries' => TRUE

And when it is run:

Quote:An uncaught Exception was encountered
Type: Error

Message: Call to undefined function mssql_pconnect()

Filename: /var/www/

Line Number: 112

Line 112 is as follows (Unmodified from the downloaded version of CI) ::
PHP Code:
        $this->conn_id = ($persistent)

Obviously there may be a package or two missing, from ubuntu, or apache, but I can not figure out which.  Help would be very much appreciated!!  Attached is output from phpinfo
1. Install sqlsrv driver:

2. Change your dbdriver into 'sqlsrv' (application\config\database.php)
Driver should also be MySQLi not MySQL
(01-11-2018, 02:15 PM)jreklund Wrote: [ -> ]1. Install sqlsrv driver:

2. Change your dbdriver into 'sqlsrv' (application\config\database.php)

Excellent - That was the push in the right direction i needed.  Thank you!