golldy golldy - 1 month ago 15
PHP Question

Sql server and Zend Framework 2 connection issues on windows machine

Is there a tutorial or any kinda documentation anywhere online for ZF2 integration with Sql Server. I have tried and tested the things which are already there and where some are deprecated as well.

The SQLSRV is pretty painful driver to get it working, in one of the examples, i tried downloading the extensions and enabling it in the php.ini files as well. i have had no luck.

This is the closest that i got to. But it doesn't seem like its working. http://samsonasik.wordpress.com/2013/03/08/zend-framework-2-working-with-sql-server/#comments

An exception was raised while creating "Album\Model\AlbumTable"; no instance returned
this is the error that i encounter if i run the akrabat zf2-tutorial application with sql server.

this is how my global.php looks like

return array(
'db' => array(
'driver' => 'Sqlsrv',
'server' => 'servername',
'Database' => 'databasename',
'USER' => 'sa',
'password' => 'password'
);
'service_manager' => array(
'factories' => array(
'Zend\Db\Adapter\Adapter' => 'Zend\Db\Adapter\AdapterServiceFactory',
),
),
);

Answer

I know this is an old post but I had a similar problem getting php7 to work with sqlsrv on zend framework 3 on a windows machine running apache. What I did is:

First enable logging in php.ini by uncommenting error_log = php_error.log. I also gave it a full path name for example: error_log = c:\php7\php_errors.log

Secondly I changed the location of the extension folder to be the full path. extension_dir = "c:\php7\ext"

Third I went to the php7 directory and found the driver I wanted to use. (if you don't have one then find a sqlsrv php7 driver. They do exist.) I added the line extension=php_sqlsrv_7_ts_x86.dll

Then just restart your web server.

I hope this helps someone.