Reputation: 1724
I am using Symfony for quite sometime now, and I have no trouble in connections in Mysql database, until I decided to use Microsoft SQL server as the database.
This is how I configure my paramters.yml
parameters:
#database_host: 127.0.0.1
database_host: MENGGAY//SQL server tells it is the host name
database_port: null
database_name: Paycom
database_user: MENGGAY\ian
database_password: ~
mailer_transport: smtp
mailer_host: 127.0.0.1
mailer_user: null
mailer_password: null
secret: ThisTokenIsNotSoSecretChangeIt
config.yml
doctrine:
dbal:
driver_class: Realestate\MssqlBundle\Driver\PDODblib\Driver
host: "%database_host%"
port: "%database_port%"
dbname: "%database_name%"
user: "%database_user%"
password: "%database_password%"
charset: UTF8
I am using bundle here
"realestateconz/mssql-bundle": "master-dev"
And of course pdo_sqlsrv already installed, I am using WAMP here.
When I run
php bin/console doctrine:database:create
got an error
Could not create database [Paycom] for connection named default Notice: Undefined property: Doctrine\DBAL\Connection::$options
Symfony.com says it does support Ms SQL Server, however it does not provide exact guide how to configure parameters.yml for the Ms SQL server
SQL server successfully running in my windows machine Any guide to connect this succesfully? Any Ideas?
Upvotes: 0
Views: 833
Reputation: 1724
Solve
First by fixing the parameters.yml
database_host: MENGGAY\SQLEXPRESS
Notice the backlash \ and SQLEXPRESS
Next in config.yml
driver_class: pdo_sqlsrv
I am using WAMP, so I have to make sure pdo_sqlsrv is enabled and added the pdo_sqlsrv in php.ini, again by clicking the WAMP icon
Well it is enabled, but it does not show up when running
<?php info(); ?>
Thus returning an error
driver not found
The trick is
Go to your project folder
In commandline, I am using Gitbash here
cd c:/wamp/www/MyProject
php --ini
Now this will point me where to put pdo_sqlsrv.dll to the right php.ini file
Move pdo_sqlsrv.dll to the right php.ini
Restart WAMP
run again
php bin/console doctrine:database:create
And hoola, success!
Upvotes: 0
Reputation: 1280
You use a custom MsSQL driver, so that's not a symfony problem.
Have you tried with clean pdo_sqlsrv
driver?
MssqlBundle is not maintained anymore.
Upvotes: 1