This topic is locked

Emojis in the database

12/4/2024 4:54:28 PM
PHPRunner Tips and Tricks
Sergey Kornilov admin

Here is what you need to do in order to store and retrieve text with emojis in the database. This tutorial applies to PHPRunner 10.91 and MySQL.

  1. Create database and database tables. Important: use charset utf8mb4 and collation utf8mb4_unicode_ci when you create database and tables. It is also possible to change the collation of existing database but in out example we will show how to

Create database:
CREATE DATABASE emoji DEFAULT CHARSET = utf8mb4 DEFAULT COLLATE = utf8mb4_unicode_ci;

Create database table:

CREATE TABLE IF NOT EXISTS `emoji` (
`id` int(11) DEFAULT NULL,
`name` varchar(100) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
  1. In PHPRunner make sure that "Unicode (UTF-8)" is selected as Output Code Page on Miscellaneous screen.


  2. Add the following code to AfterAppInit event
    $cMySQLNames = "utf8mb4";



And the end result:

img alt

C
Corrie De Wet 12/5/2024

Very Nice. I am now thinking to build a nice and eazy chat interface for users that use the same application.