This library is currently available only via the outlast plugin but will be moved to system shortly.

This library provides a standardized helper interface to connect to a Microsoft SQL Server instance.

You can read about required server settings and modules here.


You can set up an mssql.conf.ini file with the necessary server, user, password, port, and database information. The mssql library will connect to this by default. You should set up a separtate connection for production and development environments by setting the key/value pairs in each section of the config file. Development will be used when debug_mode is true, so typically on localhost and development servers.


Connect to the SQL Server. This will happen automatically on the first query but can be triggered manually as well. Use the parameter to load a custom configuration file.

@param string|boolean $custom_conf_file Use a custom configuration file for connection data. Defaults to mssql.conf.ini
@return boolean Returns true or false on fail.


Run a query on the current connection and connect to the server if not yet connected.

@param string $query The SQL query to run.
@return zajlib_mssql_resultset|boolean An iterator for going throught the results.

The resulting object is a resultset which can be iterated with foreach or you can call next() on it to get the next row and rewind() to return to row 0. It also has the following properties:
total - integer - The total number of rows in the result set.
affected - integer - The total number of affected rows.
last_error - string - The last error message.


Get the last error message. You can also use the last_error property on the result set object.

@return string The error message.


Escapes a value for mssql to prevent SQL injection.

@param string $value The value to escape
@return string The escaped string.

Outlast Web & Mobile Development (c) 2018 | Privacy Policy |