X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=catagits%2FCatalyst-Manual.git;a=blobdiff_plain;f=lib%2FCatalyst%2FManual%2FTutorial%2F04_BasicCRUD.pod;h=5ba0efefc2743bacb7ba6134035ce930227e2e1c;hp=fc938df7ebc1cadb60d7e40f434df86bd17f43e7;hb=24acc5d75bb4208eeef4d1bad0974f0fd5893454;hpb=22fe0f18ac89a984b2a27ff0eb146f485cfb9a8c diff --git a/lib/Catalyst/Manual/Tutorial/04_BasicCRUD.pod b/lib/Catalyst/Manual/Tutorial/04_BasicCRUD.pod index fc938df..5ba0efe 100644 --- a/lib/Catalyst/Manual/Tutorial/04_BasicCRUD.pod +++ b/lib/Catalyst/Manual/Tutorial/04_BasicCRUD.pod @@ -60,12 +60,13 @@ This chapter of the tutorial builds on the fairly primitive application created in L to add basic support for Create, Read, Update, and Delete (CRUD) of C -objects. Note that the 'list' function in Chapter 3 already implements -the Read portion of CRUD (although Read normally refers to reading a -single object; you could implement full Read functionality using the -techniques introduced below). This section will focus on the Create and -Delete aspects of CRUD. More advanced capabilities, including full -Update functionality, will be addressed in +objects. Note that the 'list' function in +L already +implements the Read portion of CRUD (although Read normally refers to +reading a single object; you could implement full Read functionality +using the techniques introduced below). This section will focus on the +Create and Delete aspects of CRUD. More advanced capabilities, +including full Update functionality, will be addressed in L. Although this chapter of the tutorial will show you how to build CRUD @@ -74,8 +75,9 @@ of tool to automate the process. You get less control, but it can be quick and easy. For example, see L, L, and L. -You can check out the source code for this example from the Catalyst -Subversion repository as per the instructions in +Source code for the tutorial in included in the F directory +of the Tutorial Virtual machine (one subdirectory per chapter). There +are also instructions for downloading the code in L. @@ -594,14 +596,14 @@ Edit C and update it to match the following header, and 2) the five lines for the Delete link near the bottom): [% # This is a TT comment. -%] - + [%- # Provide a title -%] [% META title = 'Book List' -%] - + [% # Note That the '-' at the beginning or end of TT code -%] [% # "chomps" the whitespace/newline at that end of the -%] [% # output (use View Source in browser to see the effect) -%] - + [% # Some basic HTML with a loop to display books -%] @@ -786,8 +788,6 @@ cascading delete operation via the DBIC_TRACE output: SELECT me.id, me.title, me.rating FROM book me WHERE ( ( me.id = ? ) ): '6' DELETE FROM book WHERE ( id = ? ): '6' - SELECT me.book_id, me.author_id FROM book_author me WHERE ( me.book_id = ? ): '6' - DELETE FROM book_author WHERE ( author_id = ? AND book_id = ? ): '4', '6' =head2 Fixing a Dangerous URL @@ -896,7 +896,10 @@ query parameter: Although the sample above only shows the C div, leave the rest of the file intact -- the only change we made to the C was to add "C<|| c.request.params.status_msg>" to the -Cspan class="message"E> line. +Cspan class="message"E> line. Note that we definitely want +the "C<| html>" TT filter here since it would be easy for users to +modify the message on the URL and possibly inject harmful code into the +application if we left that off. =head2 Try the Delete and Redirect With Query Param Logic @@ -942,6 +945,15 @@ book was added and when each book is updated: sqlite> .quit $ +Here are the commands without the surrounding sqlite3 prompt and output +in case you want to cut and paste them as a single block (but still +start sqlite3 before you paste these in): + + ALTER TABLE book ADD created TIMESTAMP; + ALTER TABLE book ADD updated TIMESTAMP; + UPDATE book SET created = DATETIME('NOW'), updated = DATETIME('NOW'); + SELECT * FROM book; + This will modify the C table to include the two new fields and populate those fields with the current time. @@ -970,11 +982,11 @@ call to C. However, also notice that the C relationships we manually added below the "C<# DO NOT MODIFY...>" line were automatically preserved. -While we have this file open, let's update it with some additional -information to have DBIC automatically handle the updating of these two -fields for us. Insert the following code at the bottom of the file (it -B be B the "C<# DO NOT MODIFY...>" line and B the -C<1;> on the last line): +While we C open, let's update it with +some additional information to have DBIC automatically handle the +updating of these two fields for us. Insert the following code at the +bottom of the file (it B be B the "C<# DO NOT MODIFY...>" +line and B the C<1;> on the last line): # # Enable automatic date handling @@ -1376,6 +1388,10 @@ output should be the same even though the backend code has been trimmed down. +You can jump to the next chapter of the tutorial here: +L + + =head1 AUTHOR Kennedy Clark, C
TitleRatingAuthor(s)Links