简体   繁体   English

如何将印地语数据插入 MySQL 并从中获取相同的数据

[英]How to insert Hindi data into, and fetch the same data from, MySQL

I don't know how to insert Hindi data into a MySQL database and fetch the same data from the database using Codeigniter.我不知道如何将印地语数据插入 MySQL 数据库并使用 Codeigniter 从数据库中获取相同的数据。 Please guide me.请指导我。

public function add_tag_description() // this is my controller name
    {
        $this->load->helper('form');
        $post = $this->input->post();
        $post['add_tag_description'] = $this->input->post('add_tag_description');
        unset($post['submit']);

        $this->load->model('Prediction_model', 'prediction');
        if($this->prediction->add_tag_description($post)) {
            $this->session->set_flashdata('feedback', 'Tag Description added successfully');
            $this->session->set_flashdata('feedback_class', 'alert-success');
        } else {
            $this->session->set_flashdata('feedback', 'Tag Description failed to add successfully, please try again');
            $this->session->set_flashdata('feedback_class', 'alert-danger');
        }
        $this->load->view('admin/add_tag');
    }

Model :型号 :

public function add_tag_description($post)
    {
         $add_tag_description = $post['add_tag_description'];
         $add_tag = array(
             'description'  => $add_tag_description
            );
         $this->db->insert('tag_description',$add_tag);
    }

If you are facing a MySQL database issue, you should change the charset to utf8 and collate utf8_general_ci for the column you want to store Hindi data in. Try the below query to alter your table column.如果您面临 MySQL 数据库问题,您应该将字符集更改为utf8并为要存储印地语数据的列整理utf8_general_ci 。尝试以下查询来更改您的表列。

ALTER TABLE `<table_name>` CHANGE `<field_name>` `<field_name>` VARCHAR(100) 
CHARSET utf8 COLLATE utf8_general_ci DEFAULT '' NOT NULL;

If you are having trouble while printing data on a view page, just add a meta tag in the page's header section, like the below code:如果您在查看页面上打印数据时遇到问题,只需在页面的标题部分添加一个元标记,如下面的代码:

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
ALTER TABLE `<table_name>` CHANGE `<field_name>` `<field_name>` VARCHAR(100) 
CHARSET utf8 COLLATE utf8_general_ci DEFAULT '' NOT NULL;

If you facing print data on view page. 如果您在查看页面上面对打印数据。 just add meta in header section. 只需在标头部分添加meta。 Like below code. 像下面的代码。

CODE : 代码:

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

Run this query运行此查询

ALTER TABLE `table_name` CHANGE `column_name` `column_name` TEXT CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL;

Add this code inside head tag将此代码添加到 head 标签中

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM