php - Substring with dots -


i using substring function retreive "excerpt" of message body:

select m.id, m.thread_id, m.user_id, substring(m.body, 1, 100) body, m.sent_at message m; 

what add 3 dots end of substring, if source string more upper limit (100 characters), i.e. if substring had cut off string. if source string less 100 characters no need add dots end.

i using php scripting language.

that can done in query, rather php, using:

select m.id, m.thread_id, m.user_id,         case           when char_length(m.body) > 100 concat(substring(m.body, 1, 100), '...')          else m.body        end body,         m.sent_at   message m 

the term 3 trailing dots "ellipsis".


Comments

Popular posts from this blog

java - SNMP4J General Variable Binding Error -

sql server - python to mssql encoding problem -

windows - Python Service Installation - "Could not find PythonClass entry" -