3

I am trying to seed my DB categories Table with Hebrew content. I can seed my Table with English. can someone please tell me how can I do that?

OK so it is still not working.. I tried using 'utf8_general_ci' and also the "N'אופנה".

There are my files:

database.php

'mysql' => [
            'driver'    => 'mysql',
            'host'      => env('DB_HOST', 'localhost'),
            'database'  => env('DB_DATABASE', 'forge'),
            'username'  => env('DB_USERNAME', 'forge'),
            'password'  => env('DB_PASSWORD', ''),
            'charset'   => 'utf8',
            'collation' => 'utf8_general_ci',
            'prefix'    => '',
            'strict'    => false,
        ]

DatabaseSeeder.php

DB::table('categories')->insert(array(
                array('id' => NULL, 'category_name' => "N'אופנה", 'created_at' => date("Y-m-d h:i:s"), 'updated_at' => date("Y-m-d h:i:s") ),
                array('id' => NULL, 'category_name' => 'aaa', 'created_at' => date("Y-m-d h:i:s"), 'updated_at' => date("Y-m-d h:i:s") ),
        ));

database structure

database structure

categories structure

enter image description here

categories table

enter image description here

my project encoding

my project encoding

Doron Mor
  • 71
  • 9

2 Answers2

1

YES I solved the problem !! ok so how to fix that? there you go:

Inside PHP Storm ->

changing the font in "Settings | Appearance | Override default fonts"

looks like the font used by the GUI Theme is not fully unicode

there is the link that I found my answer :)

Hebrew when creating files/projects

Thank you everyone for your time.

Doron Mor
  • 71
  • 9
0

If you're not using forge then try this maybe this will work.

Try changing your database to this:

   'mysql' => [
        'driver'    => 'mysql',
        'host'      => env('DB_HOST', 'localhost'),
        'database'  => env('DB_DATABASE', 'ibay'),
        'username'  => env('DB_USERNAME', 'root'),
        'password'  => env('DB_PASSWORD', ''),
        'charset'   => 'utf8',
        'collation' => 'utf8_unicode_ci',
        'prefix'    => '',
        'strict'    => false,
    ]

Or you could try this if the first didn't work:

     'mysql' => [
        'driver'    => 'mysql',
        'host'      => 'localhost',
        'database'  => 'ibay',
        'username'  => 'root',
        'password'  => '',
        'charset'   => 'utf8',
        'collation' => 'utf8_unicode_ci',
        'prefix'    => '',
        'strict'    => false,
    ]

In databaseSeeder.php

 return DB::table('categories')->insert(array(
            array('id' => NULL, 'category_name' => 'אופנה', 'created_at' => date("Y-m-d h:i:s"), 'updated_at' => date("Y-m-d h:i:s") ),
            array('id' => NULL, 'category_name' => 'aaa', 'created_at' => date("Y-m-d h:i:s"), 'updated_at' => date("Y-m-d h:i:s") )
    ));

In your database schema:

Change your database collation to utf8 collate utf8_general_ci

If the above is not also working try to change your queries to:

 return DB::table('categories')->insert(array(
            array('id' => NULL, 'category_name' => "N'אופנה", 'created_at' => date("Y-m-d h:i:s"), 'updated_at' => date("Y-m-d h:i:s") ),
            array('id' => NULL, 'category_name' => 'aaa', 'created_at' => date("Y-m-d h:i:s"), 'updated_at' => date("Y-m-d h:i:s") )
    ));

N stands for National language character set. Which means that you are passing an NCHAR, NVARCHAR or NTEXT value

aldrin27
  • 3,407
  • 3
  • 29
  • 43