简体   繁体   中英

Connecting to MsSql Db through Zend framework SQLSTATE[] (null) (severity 0)

i have a problem connecting to a db (mssql) from my mac. I have already installed freetds and dblib with homebrew ad they should be working but my phpinfo() says this:

 '--enable-pdo' '--with-pdo-sqlite' '--with-pdo-mysql=mysqlnd' '--with-readline=/usr/local/readline-6.2' '--with-libedit' '--with-pdo-pgsql' '--with-iconv' '--with-sqlite3' '--disable-phar' '--enable-xmlwriter' '--enable-xmlreader' '--enable-mysqlnd' 

After this, in a lone section:

Additional .ini files parsed: /usr/local/zend/etc/conf.d/pdo_dblib.ini, /usr/local/zend/etc/conf.d/mssql.ini,

And then:

 pdo_dblib
 PDO Driver for FreeTDS/Sybase DB-lib   enabled
 Flavour    freetds 

 mssql
 MSSQL Support  enabled
 Active Persistent Links    0
 Active Links   0
 Library version    FreeTDS 

I can't understand if the library is effectively enabled as connecting with the following configuration gives me the following error:

 resources.db.adapter = pdo_mssql
 resources.db.isDefaultAdapter = true
 resources.db.params.host = "host"
 resources.db.params.port = "port"
 resources.db.params.username = "un"
 resources.db.params.password = "pw"
 resources.db.params.dbname = "name"
 resources.db.params.pdoType = dblib
 resources.db.params.charset= "utf-8"

Error:

 SQLSTATE[] (null) (severity 0) 

From ##zftalk channel on freenode:

 thats usually what you get when you use pdo->lastError() when no error has actually happened

This is my mssql support in PHPinfo()

 MSSQL Support  enabled
 Active Persistent Links    0
 Active Links   0
 Library version    FreeTDS

 Directive  Local Value Master Value
 mssql.allow_persistent On  On
 mssql.batchsize    0   0
 mssql.charset  no value    no value
 mssql.compatability_mode   On  On
 mssql.connect_timeout  5   5
 mssql.datetimeconvert  On  On
 mssql.max_links    Unlimited   Unlimited
 mssql.max_persistent   Unlimited   Unlimited
 mssql.max_procs    Unlimited   Unlimited
 mssql.min_error_severity   10  10
 mssql.min_message_severity 10  10
 mssql.secure_connection    On  On
 mssql.textlimit    Server default  Server default
 mssql.textsize Server default  Server default
 mssql.timeout  60  60  

Check your freetds configuration and resources.db.params.host = "host" setting

While ago I used this configuration to connect with php 5/ZF 1.x on RHEL - but maybe will help. host is address of SQL Server and [my-server-name] is just section name in config file.

/usr/local/etc/freetds.conf
[my-server-name]
host = 10.0.0.1
port = 1433
tds version = 8.0

and then in app.ini I used (host == configuration entry in freetds.conf)

db.config.host      = my-server-name
db.config.username  = user
db.config.password  = pass
db.config.dbname    = DBNAME

(my app.ini db.config entries should correspond to your resources.db.params )

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM