[size="4"]NOTE: All of the examples provided in the book were completed with Yii version 1.1.2. Many readers are using the latest stable version of Yii (currently 1.1.5) to following along with the examples in the book. There are some subtle API/method signature differences (esp in some of the Gii auto-generated code) between these two versions. If you are using any version other than 1.1.2 to following along, you may have to make some adjustments to the examples used in the book.[/size]
[list=1][*][size="4"]Typo/Printing: Preface, Page 1 -
The first section title reads: "What this book cover" it should read: "What this book covers" or "What is covered in this book"[/size][*][size="4"]Typo/Printing: Preface, Page 3 -
Under the Conventions section, it is describing how code words in the text are shown and it uses the sentence: “You can type in help to see a list of commands available to you within his shell” It should be “…this shell” (i.e. ‘his’ should be ‘this’)[/size][*][size=“4”]Style Formatting: Page 20 -
The sentence:
"Your application has been created successfully under /Webroot/demo/"
should still be in code format style, as it is still part of the output from running the shell command.[/size][*][size="4"]Code Fragment: Page 105 -
The code does not explicitly include the class in which the method should reside. The function is fine, but it could be misleading. The public function
testGetTypes()
needs to reside in a class. The full code is
class IssueTest extends CDbTestCase
{
public function testGetTypes()
{
$options = Issue::model()->typeOptions; $this->assertTrue(is_array($options));
}
}
[/size][*][size="4"]Typo/Printing: Page 131 - The following line is missing a closing > bracket to delimit the end of the php statement: [/size]
<b><?php echo CHtml::encode($data->getAttributeLabel('status_id')); ?:</b>
[size="4"]It should be:[/size]
<b><?php echo CHtml::encode($data->getAttributeLabel('status_id')); ?>:</b>
[*][size="4"]Typo/Printing: Page 142 -
The very beginning sentence on this page has several issues. The sentence as it is printed is impossible to understand. The entire sentence should read: [extract]"As these links originate from the issue details page, we can take advantage of the associated project, and alter the links to pass in the specific project id. We can then use that project id as the criteria to limit the Issues returned by the query in both the IssueController::actionIndex(), and IssueController::actionAdmin() methods."[/extract][/size][*][size="4"]Type/Printing: Page 142 -
There is a word 1/2 way down the page that is printed as "conssue", it should be "context": "…implemented a filter to enforce a valid project context"[/size][*][size="4"]Dated Code Snippet: Page 163 -
The auto-generated code displayed for the
UserIdentity::authenticate()
method is from a version of the yiic webapp command that is prior to 1.1.2. It should be:
public function authenticate()
{
$users=array(
// username => password
'demo'=>'demo',
'admin'=>'admin',
);
if(!isset($users[$this->username]))
$this->errorCode=self::ERROR_USERNAME_INVALID;
else if($users[$this->username]!==$this->password)
$this->errorCode=self::ERROR_PASSWORD_INVALID;
else
$this->errorCode=self::ERROR_NONE;
return !$this->errorCode;
}
[/size][*][size="4"]Code Typo: Page 190 -
sql query line [sql]primary key (projectId,userId,role)[/sql] should be [sql]primary key (project_id,user_id,role)[/sql][/size][*][size="4"]Code Typo: Page 193 -
$command->execute
is missing the parentheses. It should be
$command->execute()
[/size][*][size="4"]Informational Note: Page 198 -
You might need to define the foreign key relationship on tbl_project_user_role.project_id to automatically handle deletes of rows in the project table. Otherwise, you might get a constraint violation error when the unit test ProjectTest::testDelete() is run.
in MySQL, something like [sql]ON DELETE CASCADE ON UPDATE CASCADE[/sql]
NOTE: The book is attempting to stay database independent, and the low level DDL statements for tables are intended to be general (i.e. not MySQL specific). However, the code available for download does have all of the MySQL specific statements used.[/size][*][size="3"][size="4"]Code Typo: Page 249 -
In url manager configuration, site/commentFeed is printed, but it should be just comment/feed:
'urlManager'=>array(
'urlFormat'=>'path',
'rules'=>array(
'commentfeed'=>array('comment/feed', 'urlSuffix'=>'.xml', 'caseSensitive'=>false),
'<pid:\d+>/commentfeed'=>array('comment/feed', 'urlSuffix'=>'.xml', 'caseSensitive'=>false),
),
'showScriptName'=>false,
),
[/size][/size][*][size="4"]Typo: Page 210 -
In the 3rd paragraph down, it refers to the view file as show.php but should be view.php.[/size][*][size="4"]Code/Yii version mismatch: Page 210 - The example 1/2 way down the page of creating the link is not consistent with the other menu items. It should be:
$this->menu[] = array('label'=>'Add User To Project', 'url'=>array('adduser', 'id'=>$model->id));
[/size][size=“4”] rather than using the CHtml::link method directly. (this format will still work, but is not consistent with the other menu items)[/size][][size=“3”][size=“4”]Code Typo: Page 91 - In the listed testCreate() function, the project column fields names need to be updated: [/size][/size][size=“4”]‘createTime’ should be ‘create_time’, ‘createUser’ should be ‘create_user_id’, ‘updateTime’ should be ‘update_time’ and ‘updateUser’ should be ‘update_user_id’. The code still works and the test passes because the database will accept null values for these. But the names should be corrected.[/size][][size=“4”]Code comment at the bottom of page 205 incorrectly references password, when it should be “role” - code is correct, but the code comment is not accurate Should be [/size][color="#880000"][size=“2”]// username and role are required[/size][/color][][size=“4”][color="#1c2837"]Typo - [/color][color="#1c2837"]Page 113[/color] [color="#1C2837"]First paragraph under the heading “Adding a Filter”, last sentence.[/color] [color="#1C2837"]IssueCcontroller should read: IssueController [/color][/size][][color="#1c2837"][size=“4”]Code Typo - Page 204 - in the testUserProjectAssignment() test method, ‘project1’ is incorrectly referenced, as it should be ‘project2’. The correct method is:[/size][size=“2”]
public function testUserProjectAssignment()
{
//since our fixture data already has the two users assigned to project 1, we'll assign user 1 to project 2
$this->projects('project2')->associateUserToProject($this->users('user1'));
$this->assertTrue($this->projects('project2')->isUserInProject($this->users('user1')));
}
[/size][/color][/list]