This topic is locked

Manage information in UTF8MB using PHPRunner and MySQL.

2/1/2021 5:42:35 AM
PHPRunner Tips and Tricks
fhumanes author

On several occasions I have found that I had to store and manage characters in UTF8MB4.
In fact, it has been necessary for me on these 2 occasions.

  • In the example I did to collect the messages from an email account and store them in database tables. Now it is very fashionable that or in the title or content they put Emoji (little pictures) and these are usually characters that use UTF8MB4.
  • I have made a plugin so that "emoji" can be included in a text area field and these "emoji" are characters in UTF8MB4, so by default, using PHPRunner, I could not save this data in the database.
    Well, I have solved the problem and I want to share it with you.
  • To resolve it, the recipient field of this content must be specified as having the character set of UTF8MB4.
  • In the "after application initialized" event of our application we must put these 2 lines:



$sql = "SET character_set_results = 'utf8mb4', character_set_client = 'utf8mb4', character_set_connection = 'utf8mb4', character_set_database = 'utf8mb4', character_set_server = 'utf8mb4'";

DB::Exec($sql);


Greetings,

fernando

K
keithh0427 2/3/2021

Fernando,
Would you post the "plugin so that "emoji" can be included in a text area field" in your portal?

fhumanes author 2/4/2021



Fernando,
Would you post the "plugin so that "emoji" can be included in a text area field" in your portal?


Hi there:
It is already published.
Greetings,

fernando