Changes
Page history
dmcqu009 created page: lab 17
authored
Mar 01, 2016
by
Dan McQuillan
Show whitespace changes
Inline
Side-by-side
lab-17.md
View page @
c278df95
...
@@ -31,14 +31,11 @@ include_once "controllers/blog.php";
...
@@ -31,14 +31,11 @@ include_once "controllers/blog.php";
We want the public homepage to show a list of all blog entries found in the database. We will display the title, the first
We want the public homepage to show a list of all blog entries found in the database. We will display the title, the first
150 characters of the entry_text, and a Read more link for each of the blog entries.
150 characters of the entry_text, and a Read more link for each of the blog entries.
*
declare a new method in the Blog_Entry_Table class.
we can use the same getAllEntries method that we created for step 2.
*
use PDO prepared statements for the sql
because of the way we wrote that, we can make use of the substring.
*
use the 'try/catch' stucture when executing the query
SUBSTRING() returns a part of a string, so to return only the first part of the entry text.
*
SUBSTRING() returns a part of a string, so to return only the first part of the entry text, your $sql will look like
*
what does the 'AS intro' part of the statement do? satisfy yourself that you know (i.e. you remember the idea of an alias from term 1).
what does the 'AS intro' part of the statement do? satisfy yourself that you know (i.e. you remember the idea of an alias from term 1).
```
"SELECT entry_id, title, SUBSTRING(entry_text, 1, 150) AS intro FROM blog_entry"
```
## blog controller
## blog controller
...
@@ -147,4 +144,3 @@ i.e. inside the $entryClicked loop, you'll have
...
@@ -147,4 +144,3 @@ i.e. inside the $entryClicked loop, you'll have
```
```
check this works ok.
check this works ok.
\ No newline at end of file