From 84e520e86789c2e8f1485e08ac67db40e6c9067b Mon Sep 17 00:00:00 2001 From: Christophe HENRY Date: Tue, 28 Feb 2023 10:08:13 +0100 Subject: [PATCH] Shorten the "title" field to fit in the database --- Event.class.php | 2 +- MysqlEntity.class.php | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/Event.class.php b/Event.class.php index fb0a0c87..b32fbf92 100644 --- a/Event.class.php +++ b/Event.class.php @@ -160,7 +160,7 @@ function getTitle(){ } function setTitle($title){ - $this->title = $title; + $this->title = mb_substr($title, 0, self::LEN_STRING); } function getContent(){ diff --git a/MysqlEntity.class.php b/MysqlEntity.class.php index d57ada97..0902b549 100644 --- a/MysqlEntity.class.php +++ b/MysqlEntity.class.php @@ -18,13 +18,14 @@ class MysqlEntity private $debug = false; private $debugAllQuery = false; + const LEN_STRING = 225; function sgbdType($type){ $return = false; switch($type){ case 'string': case 'timestamp': - $return = 'VARCHAR(225) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci'; + $return = 'VARCHAR('.self::LEN_STRING.') CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci'; break; case 'longstring': $return = 'TEXT CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci';