MySql Lorum Ipsum generator

A short MySql function to generate a Lorum Ipsum text.
You can download the code in the zip file below.

The function has three parameters:
p_max_words Number: the maximum amount of words, if no min_words are provided this will be the exact amount of words in the result. Default = 50
p_min_words Number: the minimum amount of words in the result, By providing the parameter, you provide a range. Default = 0
p_start_with_lipsum Boolean: if “1″ the string will start with ‘Lorum ipsum dolor sit amet.’, Default = 0

Create exactly 3 words:

mysql>SELECT str_random_lipsum(3,NULL,NULL);
+--------------------------------+
| str_random_lipsum(3,NULL,NULL) |
+--------------------------------+
| Class facilisi dictum.         |
+--------------------------------+
1 row in set (0.00 sec)

Create exactly 20 words and let it start with “Lorum ipsum dolor sit amet.”

mysql>SELECT str_random_lipsum(20,NULL,1);
+----------------------------------------------------------------------------------------------------------------------------------------+
| str_random_lipsum(20,NULL,1)                                                                                                           |
+----------------------------------------------------------------------------------------------------------------------------------------+
| Lorem ipsum dolor sit amet. Penatibus eleifend cum amet sagittis sem per vestibulum sociosqu. Sem etiam vehicula urna scelerisque dui. |
+----------------------------------------------------------------------------------------------------------------------------------------+
1 row in set (0.00 sec)

Create max 30 words, but minimal 10, let it start with “Lorum ipsum dolor sit amet.”

mysql>SELECT str_random_lipsum(30,10,1);
+----------------------------------------------------------------------------------------------------+
| str_random_lipsum(30,10,1)                                                                         |
+----------------------------------------------------------------------------------------------------+
| Lorem ipsum dolor sit amet. Senectus erat sed est urna sollicitudin litora pulvinar felis. Varius. |
+----------------------------------------------------------------------------------------------------+
1 row in set (0.00 sec)

You can download the function in this zip file: str_random_lipsum_2012-07-07.zip

Related posts

Tags: , , , ,

One Response to “MySql Lorum Ipsum generator”

  1. Interesting little function, its a good idea to use this instead of using lorem ipsum (hard coded) on HTML pages.

Leave a Reply