2

This is my first time using ms sql with cakephp. Usually I use mysql. I've edited my database.php file:

class DATABASE_CONFIG {

var $default = array(
    'driver' => 'mssql',
    'persistent' => false,
    'host' => 'jura',
    'login' => 'sa',
    'password' => '********',
    'database' => 'clientportal',
    'prefix' => '',
);

var $test = array(
    'driver' => 'mssql',
    'persistent' => false,
    'host' => 'jura',
    'login' => 'sa',
    'password' => '********',
    'database' => 'clientportal',
    'prefix' => '',
);
}

However when I view the index page i get this error:

PHP SQL Server interface is not installed, cannot continue. For troubleshooting information, see http://php.net/mssql/

Fatal error: Call to undefined function mssql_min_message_severity() in C:\Program Files (x86)\Apache Software Foundation\Apache2.2\htdocs\clientportaladmin\cake\libs\model\datasources\dbo\dbo_mssql.php on line 123

It's coming from this constructor in the dbo_mssql.php file:

function __construct($config, $autoConnect = true) {
    if ($autoConnect) {
        if (!function_exists('mssql_min_message_severity')) {
            trigger_error(__("PHP SQL Server interface is not installed, cannot continue. For troubleshooting information, see http://php.net/mssql/", true), E_USER_WARNING);
        }
        mssql_min_message_severity(15);
        mssql_min_error_severity(2);
    }
    return parent::__construct($config, $autoConnect);
}

I have the mssql extension in the php ini file

extension=php_mssql.dll

I've been using mssql databases with PHP on my setup extensively but am wondering if its because the ini file in my php directory are php.ini file is called php.ini-development and php.ini-production but I actually use a php.ini file sitting on the root of C:

Has anyone had to deal with this before? Or anyone know what I need to do? Using W7 btw.

Jonesy

2
  • What version of php do you have? Commented Oct 13, 2010 at 8:27
  • Which version of CakePHP are you using? Commented Aug 8, 2013 at 12:20

6 Answers 6

1

You can`t use extension=php_mssql.dll in php 5.3* versions.
You need to use MSSQL driver for php
MSSQL driver


Open php.ini ,just add this line
extension=php_sqlsrv_53_ts_vc9.dll

Sign up to request clarification or add additional context in comments.

Comments

1

use proper extensions files depending upon your version of PHP, whether its Thread safe or not, what was the version of Visual C++ to build your PHP installation.

php_sqlsrv_53_ts_vc9.dll: for instance this driver is for PHP version 5.3 which is thread safe and build using Visual C++ 9, you should also ensure that you have proper php.dll in php installation dir like php5ts.dll for thread safe version of PHP 5.xx

Comments

1

I am using the SQLSRV drivers and the according dbo_sqlsrv.php datasource for CakePHP.

the DATABASE_CONFIG the looks like this

var $default = array(
    'driver' => 'sqlsrv',
    'connect' => 'sqlsrv',
    'persistent' => false,
    'host' => 'tcp:NAUFRAGADOS',
    'login' => 'sa',
    'password' => '********',
    'database' => 'geotest',
    'prefix' => 'cake_',
);

notice the 'tcp:' in the host definition. This was what I was tripping about till I've got it right

1 Comment

The tcp shouldn't actually be required. I've connected to SQL Server both locally ('host' => 'localhost') and through a remote host and neither required the tcp.
0

What's the version of CakePHP you're using ?

Another thing, please check about the extension at http://localhost/phpinfo.php.

You should find the extensions that are enabled and seen by the server.

Comments

0

The problem you have is in two parts. Firstly as others have pointed out you're using PHP 5.3 which has no mssql PHP extension. You need to use the Sqlsrv drivers, update the php.ini file and test that you can connect to SQL Server using the sqlsrv drivers.

The second problem you then have is getting CakePHP to use the sqlsrv drivers. Depending on the CakePHP version you have you might need to install the separate sqlsrv database driver. I'm still using CakePHP 1.2 and I believe certainly also in CakePHP 1.3 you need to install the sqlsrv database drivers separately. I don't know if they've included sqlsrv drivers in CakePHP 2 yet.

There is an offical source for CakePHP v1.3+ data sources which includes a sqlsrv data source.

Comments

-1

I'm getting the same error on the server using the migrations plugin:

http://cakedc.com/eng/pierre_martin/2010/02/05/cakephp-migrations-plugin-easily-version-and-deploy-whole-applications

it works locally, and the site itself can access the MS SQL DB without problems. It's just the command line cake migration commands that give this error. I'm pretty much stuck with whatever the PHP configuration is on the server. It really would be handy to use this plugin, but I'm not sure where to start looking or tweaking to track this down, but I wonder if it's the same underlying issue?

1 Comment

This is not actually an answer - this should be a comment

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.