Advertisement
Guest User

Untitled

a guest
Oct 6th, 2016
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.16 KB | None | 0 0
  1. * Cài đặt FreeTDS
  2.  
  3. $ apt-get install libsybdb5 freetds-common php5-sybase
  4.  
  5. * Thêm cấu hình trong config/database.php trong Laravel 5
  6.  
  7. ```php
  8. 'sqlsrv' => [
  9. 'driver' => 'sqlsrv',
  10. 'host' => env('DB_HOST', 'localhost'),
  11. 'database' => env('DB_DATABASE', 'forge'),
  12. 'username' => env('DB_USERNAME', 'forge'),
  13. 'password' => env('DB_PASSWORD', ''),
  14. 'charset' => 'utf8',
  15. 'prefix' => '',
  16. ]
  17. ```
  18.  
  19. * Sử dụng thêm DB::raw("N'Phạm Văn Trung'") vào trường tiếng viêt trong database
  20.  
  21. ```php
  22. DB::table('users')->insert([
  23. 'name' => DB::raw("N'Phạm Văn Trung'"),
  24. 'username' => 'trungpv93',
  25. 'email' => 'email@gmail.com',
  26. 'password' => bcrypt('ABCXYZ'),
  27. ]);
  28. ```
  29.  
  30. ```php
  31. $user = new User();
  32. $user->name = DB::raw("N'Phạm Văn Trung'");
  33. $user->username = 'trungpv93';
  34. $user->email = 'email@gmail.com';
  35. $user->password = bcrypt('ABCXYZ');
  36.  
  37. $user->save();
  38. ```
  39.  
  40. * Note (Option): Nếu có vấn đề về tiếng việt thì sửa lại tds version trong /etc/freetds/freetds.conf
  41.  
  42. ```
  43. tds version = 8.0
  44. ```
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement