dmcqu009 created page: lab 17 authored by Dan McQuillan's avatar Dan McQuillan
......@@ -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
......@@ -147,4 +144,3 @@ i.e. inside the $entryClicked loop, you'll have
```
check this works ok.
\ No newline at end of file