selectByID
This method retrieves a single row from the table. The row is identified by its id column. selectBylD doesn't return the content of the row, it returns TRUE or FALSE to indicate whether the requested row was found. If the selectByID function can't find the row that is being looked up, it stores a message in the object explaining that no such object exists in the data — that can be retrieved by calling the getMessage method. The following numbers refer to line number in Listing 8-17.
- 38 Because all the forum tables contain a column named id, you can simply hard-code a SELECT statement in this method. If you want to extend TableAccessor to access a table that doesn't contain a column named id (or if you need to access the table by some other set of columns), you can override the selectByID method in your own class. (In fact, you do just that when you create the Post class a little later.)
- 48 If selectByID finds the requested row, it stores the row values in
- this->currentRow (which is a protected member of the TableAccessor class) and returns TRUE to indicate success.
- 54 If selectByID can't find the requested row, it stores a message in
- this->message and returns FALSE.
Post a comment