- ISBN13: 978-1-4302-0977-5
- ISBN10: 1-4302-0977-1
- 344 pp.
- Published Jul 2008
- Print Book Price: $42.99
- eBook Price: $30.09
Errata Submission
If you think that you've found an error in Beginning CakePHP: From Novice to Professional, please let us know about it. You will find any confirmed erratum below, so you can check if your concern has already been addressed.
Errata
| Issue | Author's Response |
|---|---|
| As of 2/11/2010 CakePHP 1.2 Chapter 8, adding Comments to Ajax post in the view.ctp for Post I had to use this in place of $ajax->form: <?php echo $ajax->form(array('type' => 'post','options' => array( 'model'=>'Comment', 'update'=>'comments', 'url' => array( 'controller' => 'comments', 'action' => 'add' ) ) )); ?> |
Some changes to Cake 1.2's routing structure have required adjustments with the Ajax helper. |
| chapter 8, page 121: line 5 of Listing 8-8 is missing a closing parens: $comments=$this->Comment->find('all',array('conditions'=>array('post_id'=>$this->data['Comment']['post_id']),'recursive'=>-1); should be $comments=$this->Comment->find('all',array('conditions'=>array('post_id'=>$this->data['Comment']['post_id']),'recursive'=>-1)); |
Add the closing parenthesis and it should resolve the problem, as noted. |
| Chapter 7, Page 107, Listing 7-9, Line 4 The syntax for the conditions in the findByYear() function is incorrect. Here is the code: return $this->find('all', array('conditions'=>array('DATE(Post.date)'=>'>'.$date,'DATE(Post.date)'=>'<'.$end_date))); Written this way, the WHERE clause of the SQL statement that is generated looks like so: DATE(`Post`.`date`) = '<2008-12-31 23:59:59' I checked the Cookbook and found that the relational operators should be part of the key, rather than the value. The correct syntax should be: return $this->find('all', array('conditions'=>array('DATE(Post.date) >'=>$date,'DATE(Post.date) <'=>$end_date))); This resulted in the correct WHERE clause for me: WHERE DATE(`Post`.`date`) > '2008-01-01 00:00:00' AND DATE(`Post`.`date`) < '2008-12-31 23:59:59' This error also occurs in listing 7-12 on page 109. |
You're correct. RC2 and greater requires that relational operators for SQL queries appear in the key of the conditions array and not in the value. Just to reiterate, replace Listings 7-9 line 4 and 7-12 line 5 with: return $this->find('all',array('conditions'=>array('DATE(Post.date) >'=>$date,'DATE(Post.date) <'=>$end_date))); |
| Maybe it is the version of cakephp I'm using (1.2.0.7692) but the view file you had me create in Chapter 6, page 85, for the add action did not save the user id properly. The confusing part was it was saved properly with the baked view file but not after replacing it with your example. I went back and looked and the baked view used e($form->input('user_id') and not e($form->input('User') |
In many cases, $form->input('User') should check out, but it does appear that later versions of Cake have adjusted how strict it maps associated models. Your best bet is to use here: $form->input('user_id') |
| Chap 6, page 74. Instructed to add <? $session->flash(); ?> to app/views/layouts/default.ctp Did that, but it doesn't change the display at all. |
As explained in this chapter, the display only changes when an error occurs and $session->setFlash() is used in the controller. This code works as explained here, you'll have to pay attention for those situations when an error call is written in the controller and then occurs during execution. |
| Chapter 8, page 116 $javascript->link(array('prototype')J; should be something like echo $javascript->link(array('prototype')J; My actual code in default.ctp is <head> <title>My Cake Blog Application</title> <?=$html->css('cake.generic');?> <?=$javascript->link(array('prototype')); ?> </head> |
I don't consider this a mistake in the text. At this point in the book, I have already discussed echoing (particularly with short tags), and I expect the reader to know at this point how to echo lines in views, including layouts. |
