Welcome Guest, Not a member yet? Register   Sign In
Database classes for SQL Server 2005 and SQL Server 2008 (using php_sqlsrv.dll from the Microsoft Data Programmability t

Can someone help me with this issue: http://ellislab.com/forums/viewthread/132942/ ?

Sorry for the lack of replies. I found a few minutes to update the driver to work with the newest
version of the DLL. Thanks to everybody that used it, or made modifications & improvements.

I've updated the driver for the new PHP SQLSRV 1.1 CTP that Microsoft have released. It includes:

* Working support for num_rows()
* UTF-8 support (untested, but certainly sets the charset correctly at connection time)
* Support for CodeIgniter 1.7.2 (missing functions are now implemented, if applicable)

You can get more information at: http://www.phrenzy.org/code/sql-server-and-php
You can download the driver at: http://www.phrenzy.org/code/sqlsrv-1.1.tar.gz

I just wanted to say a huge thank you to the author of the sqlsrv driver for CI. This has helped me no end and has provided a fast stable SQL driver for CI.

Just a note to people struggling to get this to work, you must ALSO have installed the mssql native php drivers on your web server. You can download these at


Thanks again

Also a quick update / required fix needed in the sqlsrv_driver.php file

When using active record in CI, the database driver looks for the var $_like_escape_str in the sqlsrv driver file above however this is called _escape_char. Need to rename this var in /sqlsrv/sqlsrv_driver.php from




To prevent isset warning errors errors. Hope this may help someone.


Is there a way to get this driver to work with the pagination library?
So far it is MUCH faster than the mssql driver with 2005, and I'd really like to use it. I'm very new to CI so I could be missing something obvious, but when attempting to use the pagination library, my result records display but I get no pagination links. I've also tried to use a stored procedure to get my result set, but I'm getting this:

A Database Error Occurred
Error Number: 01000

[Microsoft][SQL Server Native Client 10.0][SQL Server]Executing SQL directly; no cursor.

Does this driver force you to use a cursor for some reason?

Ok, got the pagination working. I had to change

$config["total_rows"] = $this->db->get('table')->num_rows();


$config["total_rows"] = $this->db->count_all('table');

I'm so impressed by the speed of this driver! Now I just have to figure out how to call stored procedures....

I'm trying to get multiple result sets working with this driver. Has anyone done that yet?

I would really really like to be able to execute store procedures since im passing a full application to PHP from JSP and it's mainly based on store procedures, is there any way to achieve it?
Thanks in advance!

[eluser]Bojan Sudarević[/eluser]
[quote author="aj2000" date="1267205812"]When using active record in CI, the database driver looks for the var $_like_escape_str in the sqlsrv driver file above however this is called _escape_char. Need to rename this var in /sqlsrv/sqlsrv_driver.php from




To prevent isset warning errors errors[/quote]

In fact, I think that you should declare both of them, if you want to avoid errors. Currently CI_DB_sqlsrv_driver class declares these $_escape_char and $dbdriver properties, and it doesnt declare: $_like_escape_str, $_like_escape_chr, $_count_string, $_random_keyword. I presume that these properties can be safely copied from CI_DB_mssql_driver class:

// clause and character used for LIKE escape sequences
    var $_like_escape_str = " ESCAPE '%s' ";
    var $_like_escape_chr = '!';
     * The syntax to count rows is slightly different across different
     * database engines, so this string appears in each driver and is
     * used for the count_all() and count_all_results() functions.
    var $_count_string = "SELECT COUNT(*) AS ";
    var $_random_keyword = ' ASC'; // not currently supported

CI 1.73
mssql server 2000
windows 2003
SQLServerDriverForPHP 2.0

If the query no data will appear the following error:

A PHP Error was encountered
Severity: Notice
Message: Undefined variable: num_rows
Filename: sqlsrv/sqlsrv_result.php
Line Number: 48

Theme © iAndrew 2016 - Forum software by © MyBB