SQLSTATE [HY000] - PDOException - Laravel 4

时间:2013-12-26 20:21:06

标签: php sql-server freetds unixodbc

我正在Laravel 4使用CentOS 5PHP 5.4。当我尝试运行查询时,我得到了这个:

PDOException
SQLSTATE[HY000] Attempt to set unknown LOGINREC field (severity 7)

只是一个简单的查询,例如:User::find(1);(使用Eloquent ORM)。

我的FreeTDS配置:

[myconf]
        host = 172.30.1.24
        # tried with port 1433 and 1453
        port = 1453
        # tried with tds 8.0 and 7.0
        tds version = 7.2

Laravel数据库配置:

            ....
            'sqlsrv' => array(
                    'charset'  => 'iso-8859-1',
                    'driver'   => 'sqlsrv',
                    'host'     => 'myconf',
                    'database' => 'mydb',
                    'username' => 'myuser',
                    'password' => 'mypass',
                    'prefix'   => '',
            ),

当我运行“tsql -C”时:

Compile-time settings (established with the "configure" script)
                            Version: freetds v0.82
             freetds.conf directory: /etc
     MS db-lib source compatibility: yes
        Sybase binary compatibility: yes
                      Thread safety: yes
                      iconv library: yes
                        TDS version: 4.2
                              iODBC: no
                           unixodbc: yes

php -v

PHP 5.4.23 (cli) (built: Dec 11 2013 06:57:28) 
Copyright (c) 1997-2013 The PHP Group
Zend Engine v2.4.0, Copyright (c) 1998-2013 Zend Technologies
    with the ionCube PHP Loader v4.4.4, Copyright (c) 2002-2013, by ionCube Ltd., and
    with Xdebug v2.2.3, Copyright (c) 2002-2013, by Derick Rethans

1 个答案:

答案 0 :(得分:0)

解决

  1. 安装新的Freetds
  2. 配置freetds.conf
  3. 使用remi repo(yum --enablerepo=remi install php-mssql
  4. 重新安装php-mssql
  5. 重启apache

    • 启用了dblib并按预期工作。