Laravel: Generated SQL throws error only on specific tables

前端 未结 2 1501
太阳男子
太阳男子 2021-01-14 13:59

I am accessing MS SQLServer through Laravel, using Eloquent ORM or Query Builder. This works fine on all tables, but one particular table throws this error:

         


        
相关标签:
2条回答
  • 2021-01-14 14:20

    Please try :

    $handle = getHandle();
        $handle->exec('SET QUOTED_IDENTIFIER ON');
         $handle->exec('SET ANSI_WARNINGS ON');
         $handle->exec('SET ANSI_PADDING ON');
         $handle->exec('SET ANSI_NULLS ON');
         $handle->exec('SET CONCAT_NULL_YIELDS_NULL ON');
    

    OR

    You can also check the server configuration: check the "/etc/freetds.conf " file and change the tds version and add client charset then in php.ini please check mssql.charset and default_charset

    in /etc/freetds.conf :

    ;tds version = 4.2
    tds version = 8.0
    client charset = UTF-8
    

    In php.ini :

    mssql.charset = "UTF-8"
    default_charset = "utf-8"
    

    Thanks.

    0 讨论(0)
  • 2021-01-14 14:32

    Laravel uses db-library (if it's available) to connect to Sql Server which cannot receive unicode data from MSSQL. (1,2)

    If you don't have to save unicode data in 'LeistungsBeschreibung', change the column datatype to varchar.

    You may want to checkout the accepted answer to a similar question: MSSQL Query issue in PHP and querying text data

    Links

    • http://msdn.microsoft.com/en-us/library/aa937590(v=sql.80).aspx (1)
    • https://github.com/laravel/framework/blob/master/src/Illuminate/Database/Connectors/SqlServerConnector.php#L47 (2)
    0 讨论(0)
提交回复
热议问题