开发者

Store data in mysql (data-migration)

开发者 https://www.devze.com 2022-12-08 09:07 出处:网络
I\'m trying to make an online dictionary for my own purposes (I know there are some other dictionaries, but they don\'t have what I need) and I have a file with words in the following format:

I'm trying to make an online dictionary for my own purposes (I know there are some other dictionaries, but they don't have what I need) and I have a file with words in the following format:

戚谊
戚誼
    [m1][b]qīyì[/b][/m]
    [m2]some translation[/m]
三州府
    [m1][b]sānzhōufǔ[/b][/m]
    [m2]translation #2[/m]

First two lines are the same character, but traditional chinese character and simplified, the third line is transcr开发者_Python百科iption, the forth line is the meaning of the character (translation). How can I store this data in proper columns of mysql database? (columns: simplified_character, trad_character, translation, transcription, etc)

Thank you!


There are three possible questions you are asking here:

  1. How to write to a MySQL database from PHP.
  2. How to read in a file from PHP and then write it to MySQL.
  3. What format to store data in MySQL.

I'm going to assume (3) but please do clarify if you intended something else. Basically, you will need to store characters in the UTF-8 format in the MySQL database to ensure that they are preserved.

You can do this by running the following query before anything else:

mysql_query("SET NAMES utf8")

All following queries should be interpreted as UTF-8.

0

精彩评论

暂无评论...
验证码 换一张
取 消