Changes
Page history
dmcqu009 created page: lab 17
authored
Mar 01, 2016
by
Dan McQuillan
Hide whitespace changes
Inline
Side-by-side
lab-17.md
View page @
c278df95
...
...
@@ -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
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.
*
use PDO prepared statements for the sql
*
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, 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).
```
"SELECT entry_id, title, SUBSTRING(entry_text, 1, 150) AS intro FROM blog_entry"
```
we can use the same getAllEntries method that we created for step 2.
because of the way we wrote that, we can make use of the substring.
SUBSTRING() returns a part of a string, so to return only the first part of the entry text.
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).
## blog controller
...
...
@@ -146,5 +143,4 @@ i.e. inside the $entryClicked loop, you'll have
include_once "views/entry-html.php";
```
check this works ok.
check this works ok.
\ No newline at end of file