Prev | Current Page 306 | Next

David Berube

"Practical Reporting with Ruby and Rails"

(You might get more entities; they all begin
with &#.)
Additionally, note the call to CONCAT, which has three parts. The first part is the call to
CONCAT itself, which adds two strings together. The next two parts are the strings to add.
The first string it concatenates is LEFT(title,40), which pulls out the leftmost 40 characters
of the title of the story. The second string is CASE WHEN length(title)>40 THEN '...'
ELSE '' END, which adds three periods after the title if the title is longer than 40 characters.
In other words, if the title is longer than 40 characters, display the first 40
characters of the title followed by three periods.
nNote Strictly speaking, the notation after the 40-character maximum in this example should be an ellipsis,
not three periods. An ellipsis is closer together, so the three periods are the width of a single character.
However, text-only applications, like the MySQL console, don??™t have ellipses.
Now let??™s take a look at the code in the loading script.
Dissecting the Code
First, the script in Listing 11-1 needs to create a connection to the database:
# If there's a config/database.


Pages:
294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318
auto giełda Pomoc poszkodowanym w wypadkach operator edi polski plakat życzenia na walentynki