I have MS SQL database with collation set to SQL_Latin1_General_CP1_CI_AS
. I am connecting to the database through PHP (Nginx server on Freebsd OS). When I am trying to save characters like ജെയിംസ്, جیمز
etc it is storing as ????
. My default_charset is UTF-8
in PHP.
UPDATE: When I tried it from my local Windows env, it was storing the characters successfully. But from the Freebsd environment it is having problem. Below is the stored procedure call from Windows and Freebsd environment respectively.
Trace from Windows machine:
declare @p1 int
set @p1=2
declare @p14 int
set @p14=0
exec sp_prepexec @p1 output,N'@P1 nvarchar(15),@P2 nvarchar(16),@P3 nvarchar(10),@P4 nvarchar(max),@P5 nvarchar(max),@P6 char(1),@P7 char(1),@P8 nvarchar(max),@P9 int,@P10 nvarchar(1),@P11 int OUTPUT',N'EXEC ValidateFBLogin_sp @p_UserName = @P1, @p_Email = @P2, @p_FBID = @P3, @p_DeviceToken = @P4, @p_IPAddress = @P5, @p_Latitude = @P6, @p_Longitude = @P7, @p_EndpointArn = @P8, @p_UserAccountTypeID = @P9, @p_DeviceType = @P10, @p_ErrID = @P11 OUTPUT',N'ആഷ്ലി',N'ashley@gmail.com',N'67463sgs7s',N'',N'',NULL,NULL,N'',2,N'1',@p14 output
select @p1, @p14
Trace from Freebsd:
EXEC ValidateFBLogin_sp
@p_UserName = 'ആഷ്ലി', @p_Email = 'ashley@gmail.com', @p_FBID = '45534552', @p_DeviceToken = '',
@p_IPAddress = '', @p_Latitude = NULL, @p_Longitude = NULL,
@p_EndpointArn = '', @p_UserAccountTypeID = 2,
@p_DeviceType = '1', @p_ErrID = 0
From windows it is prep-ending N with the in param p_UserName but in Freebsd it is not.
Update2: Regarding database connection from PHP
Laravel5.3 Framework
Connection parameters: config/database.php
return [
'sqlsrvstaging' => [
'driver' => 'sqlsrv',
'host' => 'XXXXX',
'database' => 'XXXXX',
'username' => 'XXXXX',
'password' => 'XXXXX',
'prefix' => '',
'charset' => 'UTF-8',
'strict' => false,
'pooling' => false,
]
];
Code is $this->pdo = DB::connection('sqlsrvstaging')->getPdo();