1

I have a problem connecting to a db with zend framework 1.12 and zend studio. The code in the application.ini to connect to the db is the following:

 resources.db.adapter = pdo_mssql

 resources.db.params.host = "IPADDRESS\SQLEXPRESS"
 resources.db.params.username = sa
 resources.db.params.password = XXXXXXXX
 resources.db.params.dbname = namedb
 resources.db.isDefaultTableAdapter = true
 resources.db.params.pdoType = dblib
 resources.db.params.charset= "utf-8"

The db is available online (I checked) but i get the following error:

 Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[01002] Adaptive Server connection failed (severity 9)

I know this error is a connection error (the pdo doesn't find the db) and i've found a tutorial in a forum which should help (it uses zend framework with the same libraries and type of db i use, on a mac). But i think the pdo type is configured somewhere elsein my machine as i don't find in my Abstract.php:

 protected $_pdoType = 'dblib';

The pdo type is set in the application.ini, the code i pasted before. The log says the error is in those lines:

 in /usr/local/zend/var/libraries/Zend_Framework_1/1.12.3/library/Zend/Db/Adapter/Pdo/Abstract.php:129 

            $this->_connection = new PDO(
            $dsn,
            $this->_config['username'],
            $this->_config['password'],
            $this->_config['driver_options']
        );

But i cannot understand what I'm missing.. Any hint?

2 Answers 2

1

This article by rob allen will be usefull i think , Zf Coonect To MSSQL

as described there in detail you can use following,

resources.db.adapter = "sqlsrv"
resources.db.host = "host"
resources.db.dbname = "DatabaseName"
resources.db.isDefaultTableAdapter = true 
resources.db.driver_options.ReturnDatesAsStrings = true

Hope That Helps

also relevant DOC from zend framwork official document here.

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

3 Comments

It complains about a missing extension, i should load sqlsrv to make it work i assume. How to do it?
i'm on a mac, i caanot use sqlsrv as an extesion, it doen't exist for mac. However thank you!
1

Try the following:

Microsoft SQL Server database connection info

db.mssqlServer.adapter          = PDO_MSSQL
db.mssqlServer.config.pdoType   = dblib
db.mssqlServer.config.host      = server_ip_or_url
db.mssqlServer.config.dbname    = database_name
db.mssqlServer.config.username  = "mssql_user"
db.mssqlServer.config.password  = "mssql_password"
db.mssqlServer.config.driver_options.PDO::ATTR_ERRMODE=PDO::ERRMODE_EXCEPTION

Comments

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.