Search code examples
phpmysqllaravellaravel-query-buildercharacter-set

Laravel SQLSTATE[01000]: Warning: 1265 Data truncated for column for urdu or arabic character which are RTL mean right to left


I am stuck in an error for many days, I want to insert data in database in urdu or arabic language , the problem I am facing is strange the insert query changes the position of variables which throws data truncated error , I have used the same work in register Quer which works fine , I have set character set etc every thing perfect but the problem is during inserting values. I am sending the error query which larave throws.

#
Illuminate\Database\QueryException
SQLSTATE[01000]: Warning: 1265 Data truncated for column 'calor_bane' at row 1 (SQL: insert into `service_attributes` (`calor_bane`, `user_id`, `service_id`) values (کالر, 1, 1))
This is the query elequent  
enter code here
ServiceAttribute::create([
'calor_bane' =>$data['name'], 
'user_id' => 1,
'service_id' => 1
]);
#

The same field is inserted in using User Model, it insert the urdu or arabic text correctly both char set are same but problem occurs in the insert query which moves the places you can see the above query.I have tried query builder and other types but didn't work.

insert into `users` (`name`, `email`, `password`, `updated_at`, `created_at`) values (کالر, [email protected], $2y$10$Y5fOtbpy..mgExbTotb1sO6irLlhNePKCfMvHv1JSmgtpOhUC2XLO, 2020-05-19 18:13:16, 2020-05-19 18:13:16)
User::create([
'name' => $data['name'],
'email' => $data['email'],
'password' => Hash::make($data['password']),
]);

Solution

  • Actually by changing the ENUM data type solved my problem. Thanks all.