未定义 class 常量 'SQLSRV_ENCODING_SYSTEM'
Undefined class constant 'SQLSRV_ENCODING_SYSTEM'
尝试 运行 php artisan 在 laravel 上迁移时出现错误
In database.php line 79:
Undefined class constant 'SQLSRV_ENCODING_SYSTEM'
我安装了 sql 驱动程序等,但不确定如何解决这个问题
database.php 文件
'sqlsrv' => [
'driver' => 'sqlsrv',
'host' => env('DB_HOST', 'localhost'),
'port' => env('DB_PORT', '1433'),
'database' => env('DB_DATABASE', 'forge'),
'username' => env('DB_USERNAME', 'forge'),
'password' => env('DB_PASSWORD', ''),
'charset' => 'utf8',
'prefix' => '',
'options' => [PDO::SQLSRV_ENCODING_SYSTEM => false], // Used for MSSQL encoding
],
说明:
PDO::SQLSRV_ENCODING_SYSTEM
是 PDO_SQLSRV Driver Constant
,不是选项名称。您应该在选项中使用 PDO::SQLSRV_ATTR_ENCODING => PDO::SQLSRV_ENCODING_SYSTEM
。请记住,此选项是 Microsoft Drivers for PHP for SQL Server specific driver attribute(PDO::SQLSRV_ATTR_ENCODING
和 PDO::SQLSRV_ATTR_DIRECT_QUERY
之一)。
<?php
...
'sqlsrv' => [
'driver' => 'sqlsrv',
'host' => env('DB_HOST', 'localhost'),
'port' => env('DB_PORT', '1433'),
'database' => env('DB_DATABASE', 'forge'),
'username' => env('DB_USERNAME', 'forge'),
'password' => env('DB_PASSWORD', ''),
'charset' => 'utf8',
'prefix' => '',
'options' => [PDO::SQLSRV_ATTR_ENCODING => PDO::SQLSRV_ENCODING_SYSTEM]
],
...
?>
备注:
文档:Microsoft SQL Server Functions (PDO_SQLSRV) and Constants (Microsoft Drivers for PHP for SQL Server).
尝试 运行 php artisan 在 laravel 上迁移时出现错误
In database.php line 79:
Undefined class constant 'SQLSRV_ENCODING_SYSTEM'
我安装了 sql 驱动程序等,但不确定如何解决这个问题
database.php 文件
'sqlsrv' => [
'driver' => 'sqlsrv',
'host' => env('DB_HOST', 'localhost'),
'port' => env('DB_PORT', '1433'),
'database' => env('DB_DATABASE', 'forge'),
'username' => env('DB_USERNAME', 'forge'),
'password' => env('DB_PASSWORD', ''),
'charset' => 'utf8',
'prefix' => '',
'options' => [PDO::SQLSRV_ENCODING_SYSTEM => false], // Used for MSSQL encoding
],
说明:
PDO::SQLSRV_ENCODING_SYSTEM
是 PDO_SQLSRV Driver Constant
,不是选项名称。您应该在选项中使用 PDO::SQLSRV_ATTR_ENCODING => PDO::SQLSRV_ENCODING_SYSTEM
。请记住,此选项是 Microsoft Drivers for PHP for SQL Server specific driver attribute(PDO::SQLSRV_ATTR_ENCODING
和 PDO::SQLSRV_ATTR_DIRECT_QUERY
之一)。
<?php
...
'sqlsrv' => [
'driver' => 'sqlsrv',
'host' => env('DB_HOST', 'localhost'),
'port' => env('DB_PORT', '1433'),
'database' => env('DB_DATABASE', 'forge'),
'username' => env('DB_USERNAME', 'forge'),
'password' => env('DB_PASSWORD', ''),
'charset' => 'utf8',
'prefix' => '',
'options' => [PDO::SQLSRV_ATTR_ENCODING => PDO::SQLSRV_ENCODING_SYSTEM]
],
...
?>
备注:
文档:Microsoft SQL Server Functions (PDO_SQLSRV) and Constants (Microsoft Drivers for PHP for SQL Server).