Mysq-连接如何设置能够将阿拉伯文本插入到数据库中 [英] Mysq- Conection how to set to be able to insert Arabic Text in to database

查看:36
本文介绍了Mysq-连接如何设置能够将阿拉伯文本插入到数据库中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是 config.php

this is the config.php

<? 
define('DB_SERVER', 'loalhost');
define('DB_USER', 'root');
define('DB_PASS', 'pass');
define('DB_NAME', 'dbname');
define('mysql_set_charset','utf8');
define('mysql_query','SET NAMES utf8_persian_ci');

?

当我将阿拉伯语或波斯语文本插入数据库时​​,格式会发生变化.如何将数据库中的文本保持为插入的相同格式.

when i insert arabic or persian text into database the formate changes. how i can keep the text in database as same formate of insert.

问候

推荐答案

您需要确保整个数据库中的字符集都是正确的.这意味着检查所有 3 个层,数据库、表和列.使用 utf8 &utf8_general_ci 适用于您的阿拉伯语和波斯语文本.

You need to ensure the character set is correct throughout your database. This means checking all 3 layers, database, table and column. Using utf8 & utf8_general_ci will work for your arabic and persian text.

以下查询可用于检查数据库中每个对象的字符集,您也可以在大多数 GUI 应用程序中轻松检查和更改它们.

The below queries can be used to check the character set on each of the objects in your database, you can also check and change them easily in most GUI apps as well.

SELECT character_set_name 
FROM information_schema.COLUMNS
WHERE table_schema = "YOUR_SCHEMA"
  AND table_name = "YOUR_TABLE"
  AND column_name = "YOUR_COLUMN";

表格

SELECT collations.character_set_name 
FROM information_schema.TABLES AS tables,
  information_schema.COLLATION_CHARACTER_SET_APPLICABILITY AS collations
WHERE collations.collation_name = tables.table_collation
  AND tables.table_schema = "YOUR_SCHEMA"
  AND tables.table_name = "YOUR_TABLE";

数据库(架构)

SELECT default_character_set_name 
FROM information_schema.SCHEMATA
WHERE schema_name = "YOUR_SCHEMA";

这篇关于Mysq-连接如何设置能够将阿拉伯文本插入到数据库中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆